HTML:
<form id="loginForm" data-ajax="false" action="">
<div data-role="fieldcontain">
<label for="username">Username:</label>
<input id="username" type="text" name="usern" placeholder="Username" />
</div>
<div data-role="fieldcontain">
<label for="password">Password:</label>
<input id="password" type="password" name="passw" placeholder="Password" />
</div>
<div data-role="fieldcontain">
<input type="button" id="login" value="Login" />
</div>
</form>
<!-- login page closing tags go here -->
PHP:
<?php
$data = mysqli_query($conn, "SELECT * FROM users WHERE username='$username' AND password='$password'");
if($userResult == 0){
$data_response["status"] = "error";
}
?>
连接正常,数据库已成功查询。我不确定为什么这不起作用,建议将不胜感激。
答案 0 :(得分:1)
删除:
var_dump($_POST);
“用户名”必须与$ _POST ['用户名']和名称=“用户名”
相同//php
$_POST["username"]
//html
<input id="username" type="text" name="username" placeholder="Username" />