<?php
session_start();
include("connection.php");
if(isset($_GET['submit'])) {
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('awnb') or die(mysql_erroe());
$Email=$_GET['LoginEmail'];
$password=$_GET['LoginPassword'];
if($Email!=""&&$password!="") {
$query=mysql_query("select * from users where Email='".$Email."' and Password='".$password."'") or die(mysql_error());
$res=mysql_fetch_row($query);
if($res) {
$userType = $res['Type'];
if($userType == 'user') {
$_SESSION['Email']=$Email;
header("location:profileuser.php");
exit;
} else if($userType == 'sec') {
$_SESSION['Email']=$Email;
header("location:profile.php");
exit;
}
} else {
echo "
<script type='text/javascript'>
alert('Username or Password is incorrect');
</script>";
header("location:index.php");
}
} else {
echo "
<script type='text/javascript'>
alert('Enter both Username and Passowrd');
</script>";
header("location:index.php");
}
}
?>
- 在這種類型的代碼是在表中的一個屬性,它講述了用戶的類型,有兩種類型的用戶稱爲用戶或仲的。如果類型是用戶,它應該重定向到profileuser.php否則到profile.php,但我無法根據用戶類型重定向頁面。
當你嘗試重定向時,你得到的錯誤是什麼? – 2015-04-05 17:01:13
注意:未定義的索引:輸入第16行的C:\ xampp \ htdocs \ login_phpform.php – Harindranath 2015-04-05 17:02:47
@Harindranath:然後數據庫的結果中沒有「Type」列。 – David 2015-04-05 17:04:02