我正在创建一个登录表单,它查询数据库以了解用户是否存在。这个脚本在我自己的服务器上运行良好,但是一旦我在我的大学服务器上尝试过,我就得到了标题中的错误。我认为问题与我的 SQL 查询有关,但我不太确定是否诚实。
<?php
$dbhost="localhost";
$username="v22comp_B09052";
$password="-";
$db="v22comp_B09051-12-13";
$table="secrets";
// Connect to the database
mysql_connect("$dbhost", "$username", "$password") or die ("Can not connect to the database");
mysql_select_db("$db") or die ("Database is not selectable");
//Post input
$inputusername=$_POST['uid'];
$inputpassword=$_POST['upassword'];
//Check input
$sql="SELECT * FROM $table WHERE username='$inputusername' and password='$inputpassword'";
$sqlop=mysql_query($sql);
//If a row matches, output a string informing the user that they are logged in. If not, output a string informing them that they are not
$rowmatch=mysql_num_rows($sqlop);
if($rowmatch==1)
{
echo "You are now logged in";
}
else
{
echo "Invalid ID or password";
}
?>