Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/03/2016, 00:20
Avatar de polarubi
polarubi
 
Fecha de Ingreso: noviembre-2008
Mensajes: 243
Antigüedad: 16 años, 4 meses
Puntos: 2
Respuesta: mostrar dato segun registro

Cita:
Iniciado por thezzin Ver Mensaje
y el print_r() que resultado te da?

si no te da nada muestra el código php donde se inicia la sesión
Código PHP:
<?php

if(!empty($_POST)){
    if(isset(
$_POST["username"]) &&isset($_POST["password"])){
        if(
$_POST["username"]!=""&&$_POST["password"]!=""){
            include 
"conexion.php";
            
            
$user_id=null;
            
$sql1"select * from user where (username=\"$_POST[username]\" or email=\"$_POST[username]\") and password=\"$_POST[password]\" ";
            
$query $con->query($sql1);
            while (
$r=$query->fetch_array()) {
                
$user_id=$r["id"];
                break;
            }
            if(
$user_id==null){
                print 
"<script>alert(\"Acceso invalido.\");window.location='../login.php';</script>";
            }else{
                
session_start();
                
$_SESSION["user_id"]=$user_id;
                print 
"<script>window.location='../index.php';</script>";                
            }
        }
    }
}



?>