I want to create a personalized dashboard for every user and have created a login system.
I am using this code to redirect different users to different pages, but no matter what the username or password is, it is taking me into file1.php.
<?php
session_start();
if ($_SESSION['username'] == "google") {
header("location:file1.php");
}
else if ($_SESSION['username'] == "apple") {
header("location:page2.php");
}
else {
header("location:default.php");
}
?>
Here, Apple and Google are the usernames.
Here's the code that sets the session data.
$connect = @mysql_connect ($host, $username, $password) or die ('error');
$select = @mysql_select_db($db_name, $connect) or die('check');
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM $tbl_name WHERE username='$username' and password='$password' ";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
if($count==1) {
session_register("username");
session_register("passsword");
header("location:dashboard.php");
} else {
echo "Username/Password does not match. Try Again.";
}