所以基本上我正在尝试运行登录系统并使用用户的数据实时更新页面,不幸的是我无法继续会话,每次我尝试回显用户时都没有任何反应,这是我的登录代码。
<?php
$host="IPADRESS"; // Host name
$username="web11-sign-up"; // Mysql username
$password="w0lfbane01#"; // Mysql password
$db_name="web11-sign-up"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$mypassword = md5($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 result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION["$myusername"];
$_SESSION["$mypassword"];
header("location:Scene-Selection/");
}
else {
echo "Wrong Username or Password";
}
?>
直到我开始研究该网站的另一个部分时,我才意识到这部分不起作用。我无法从数据库中检索任何信息。