I'm trying to use PHP to direct to a different form depending on the username & password combo entered: ssmith goes to main_menu.php & tsmith goes to menu.php. I have tried everything I can think of, and I couldn't find anything on Google. Does anyone know how to do this? When I click the 'login' button, no matter whether I put ssmith or tsmith, it always goes to main_menu.php. Here's my current code:
<?php
//Connect to database
include "db_connect.php";
//Get variable from login form
$username=$_POST['username'];
$password=$_POST['password'];
//Check if any text has been entered in username and password
if ((empty($username)) || empty($password)){
echo "Please enter a username or password. Go back to the <a
href='Index.php'>login page</a>";
}
else {
//Check to see if username and password is found in table
$sql="SELECT * FROM accounts WHERE Username='ssmith'";
//Place the result of the sql query into the variable $result
$result=$mysqli->query($sql);
if($result=ssmith){
//Display main menu page
header("location:main_menu.php");
}
else {
//Check to see if username and password is found in table
$sql="SELECT * FROM accounts WHERE Username='tsmith'";
//Place the result of the sql query into the variable $result
$result=$mysqli->query($sql);
if($result=tsmith){
//Display menu page
header("location:menu.php");
}
else {
//Display error message
echo "Please username and password could not be found. Go back to the <a
href='Index.php'>login page</a>";
}
}
}
?>