I'm writing a login script. It's my first project I do where I use mysql and sessions. Everything went right untill this:
I wrote a login script wich, when login is correct, writes username, status, and voornaam to a session. Via "header" the visitor is redirected to the welcomepage. Here I want to read 'voornaam' and 'status' from the session. But when I run the script, where normally voornaam has to be showed, php shows status too.
This is the LogIn script:
include("inc_connect.php");
$sql = "SELECT * FROM users WHERE password='" . $POST['password'] . "' AND username='" . $POST['username'] . "'";
$result = mysql_query($sql) or die(mysql_error() . "<BR>QUery: " . $sql);
if (mysql_num_rows($result) > 0) {
//username gevonden, registreer gegevens in session
$username = mysql_result($result,0,'username');
$voornaam = mysql_result($result,0,'voornaam');
$status = mysql_result($result,0,'status');
$SESSION['username'] = $username;
$SESSION['voornaam'] = $voornaam;
$_SESSION['status'] = $status;
//doorsturen naar een beveiligde pagina
header("Location: interface.php");
exit();
this is the welcome page:
session_start();
// status bepalen
switch ($_SESSION['status']){
case "ad" : {
$status = "administrator";
}
break;
case "vw" : {
$status = "verantwoordelijke";
}
break;
case "mw" : {
$status = "medewerker";
}
break;
default:{
header("Location: LogIn.php");
}
}
and I display the variable with:
echo ($_SESSION['voornaam']);
and
echo "$status";
I hope someone can help me with this. I tried everything I know. :rolleyes: