Hi All,
How you can help me with something.
when a user logs in and is successful, i want the value of the user "type" to be stored in a session, which is then passed to the "login successful" page where i intend to use a switch statement to determine where they are to be forwarded to.
I know im almost there, but cant see my problem
This is the "checklogin.php" code, and the code after is the "login successful
$sql="SELECT user_type, user_email, user_password FROM tbl_user WHERE user_email='$user_email' and user_password='$user_password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
$user_type = $result['user_type'];
// If result matched $email and $mypassword, table row must be 1 row
if($count==1){
// Register $email, $mypassword and redirect to file "login_success.php"
session_register("user_email");
session_register("user_password");
session_register($user_type);
header("location:login_success.php");
}
else {
echo"there was a problem";
//header( "location:index.php");
}
?>
success.php
<?
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
session_start();
if(!session_is_registered(user_email)) {
header("location:index.php");
} else {
echo "This worked";
echo "you are a ";
echo $_SESSION[$user_type];
}
?>