I am creating a login page where when a doctor logs in he/she will be redirected to the doctor table according to the login credentials and when a health professional logs in they will be redirected to the health table according to their credentials. How can this be done using sql statements? Here is what i have so far which works for the doctor login:
<?php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password) {
$connect = mysql_connect("localhost","root","") or die ("Could not connect");
mysql_select_db("telestroke_database") or die ("Could not find database");
$query = mysql_query("SELECT * FROM doctor_credential_table WHERE Doctor_Username ='$username' AND Doctor_Password ='$password'") or die(mysql_error($connect));
$numrows = mysql_num_rows($query);
if ($numrows!=0) {
while ($row = mysql_fetch_assoc($query)) {
$dbusername = $row['Doctor_Username'];
$dbpassword = $row['Doctor_Password'];
$dbdoctorid= $row['Doctor_ID'];
}
$_SESSION['Doctor_Username']=$username;
$_SESSION['Doctor_ID']=$dbdoctorid;
header( 'Location: doctor_patients.php' );
} else {
echo "Incorrect Username and/or Password.<br/>
<br/><a href='Homepage.html'>Click here to return to Homepage</a>";
}
}
?>