我试图使用phpmyadmin数据库和xampp服务器在html中创建一个简单的登录但是这个错误显示* Parse错误:语法错误,意外的'$ password'(T_VARIABLE)*
这是我的代码。
<?php
$username = $_POST['user']
//*here's the Erro// $password = $_POST['pass']
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost", "root", "");
mysql_select_db("Login");
$result = mysql_query("select * from users where username = '$username' and password = '$password'") or die("Failed to query Database".mysql_error());
$row = mysql_fecth_array($result);
if ($row['username'] == $username && $row['password'] == $password ){
echo "Login Succesful! Welcome" =.$row['username'];
}else {
echo "Login Failed"
}
?>
答案 0 :(得分:2)
你忘记了分号。
$username = $_POST['user'];
你也忘了这里。
echo "Login Failed";
答案 1 :(得分:0)
您有多个错误:
<?php
$username = $_POST['user']; //<-------put ';'
//*here's the Erro// $password = $_POST['pass']
$username = stripcslashes($username);
$password = stripcslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
mysql_connect("localhost", "root", "");
mysql_select_db("Login");
$result = mysql_query("select * from users where username = '$username' and password = '$password'") or die("Failed to query Database".mysql_error());
$row = mysql_fecth_array($result);
if ($row['username'] == $username && $row['password'] == $password ){
echo "Login Succesful! Welcome =".$row['username']; //<-------change this line
}else {
echo "Login Failed";//<-------put ';'
}
?>