我正在创建一个登录页面,当医生登录时,他/她将根据登录凭据重定向到医生表,而当卫生专业人员登录时,他们将根据他们的凭据重定向到健康表。如何使用 sql 语句来做到这一点?这是我到目前为止适用于医生登录的内容:
<?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>";
}
}
?>