我已經使用this website實現了一種基本的簡單登錄方法。我可以成功登錄,但我想檢索登錄到網站的會員的名字,以將其存儲到$_SESSION
對象中。接收用戶登錄時的名字
$sql="SELECT * FROM users WHERE email='$myemail' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
//$_SESSION[];
// header("Location:http://localhost/website/test.php");
}
else
echo "Wrong Username or Password";
不要使用'mysql_'函數。他們被棄用和不安全。使用PDO:http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers – muttley91
@rar你好,我知道這一點。但對於我的課程,我的導師說他現在不介意'MySQL_'函數,下一課程,我們將使用'MySQLi'我需要使用這個函數。 – Moynul