Sessions in php for a certain user

0

Good day I'm working on WampServer php and mysql with sessions I have a problem having many users I want when I log in to show the data only of that user, my problem is how to assign an id so that when I start open with data only of that user. I have two tables User and this is related to the field user id to the table students I want to be the same page for all student users and only change the information to be displayed, I understand that with SQL JOIN but I have never used it.

$alumnos = mysql_query(“SELECT * FROM alumnos WHERE alumno = ‘$usuario’ AND password = ‘$password'”);
if(mysql_num_rows($alumno) > 0)
{
session_start();
$_SESSION[‘alumno’]=”$usuario”, $id;

header(“Location: alumnos/espacioalumno.php”);

exit();
}
    
asked by senseilex 05.11.2017 в 17:17
source

1 answer

1

You can save all the variables you want in the variable $ _SESSION, that is:

$_SESSION['alumno'] = $usuario; $_SESSION['id'] = $id;

then you do an echo:

echo $_SESSION['alumno'] . ' ' . $_SESSION['id'];

If you want to take them from the database you will also need to do a mysqli_fetch_array or something to capture the data of the query.

    
answered by 05.11.2017 / 17:45
source