PHPer第一次寻求帮助。
<?php
DEFINE ('DB_USER', 'hiddenforsecurity');
DEFINE ('DB_PSWD', 'hiddenforsecurity');
DEFINE ('DB_HOST', 'hiddenforsecurity');
DEFINE ('DB_NAME', 'hiddenforsecurity');
$email = $_POST['email'];
$password = $_POST['password'];
if($email && $password){
$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME) or die("cant connect");
$query = mysql_query("SELECT * FROM users WHERE email='$email'");
$numrows = mysql_num_rows($query);
if($numrows != 0){
echo "Account Located";
} else {
die("that user doesn't exist");
}
} else {
die("Please enter an email and a password.");
}
?>
这是我的HTML表单:
<form method="POST" action="login.php">
<div class="form-group">
<label>Email address</label>
<input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" class="form-control password" id="exampleInputPassword1" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
当我在输入中没有任何内容时按下提交时,我收到PHP中指定的错误(“请输入电子邮件和密码”)。当我提交我手动放入数据库的电子邮件和密码的测试值时,Chrome告诉我localhost无法处理此请求,http错误500.我确定这只是一个新手错误,非常感谢任何帮助。谢谢!
其他信息: 我在MAMP上运行PHP。
答案 0 :(得分:0)
你混淆了mysqli和mysql函数,因此可能导致500错误