我想用2個不同的用戶級別登錄頁面,管理員&工作人員。我如何使用下面的d代碼來做到這一點。登錄 - 用戶級別
謝謝你。
<?php
$host="localhost";
$username="root";
$password="";
$db_name="profile";
$tbl_name="company";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("Cannot Select Database");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
if($count==1){
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
header("location:Admin_home.php");
}
else {
echo "Wrong Username or Password";
}
?>
登錄成功:
session_start();
if(!session_is_registered(myusername))
{
header("location:Admin_home.php");
}
?>
<html>
<body>
Login Successful
</body>
</html>
這不是你的家庭作業網站。我們很樂意爲您提供任何*具體問題*,但您需要告訴我們問題所在。這段代碼在做什麼?你想要它做什麼?它出什麼問題了? – 2010-10-28 05:37:46
有人可以編輯這個,並至少修復他的代碼格式? – Jason 2010-10-28 05:50:50