gpt4 book ai didi

php - if(html==true) 不满足这个条件

转载 作者:可可西里 更新时间:2023-11-01 08:45:13 24 4
gpt4 key购买 nike

从表中检查电子邮件和密码后,它应该进入 studentDashBoard.php 文件。但每次我都出错,它会给出错误的 id 或 psd 错误。

这是我的 html 标记:

登录.php:

<form action="login.php" id="LoginForm" name="LoginForm" method="post" onsubmit=" return validate();">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-user"></span></span>
<input type="email" name="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" required>
</div>
<p id="statusEmail"></p>

</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-star"></span></span>
<input type="password" name="password"class="form-control" id="exampleInputPassword1" placeholder="Password" required>
</div>
<p id="statusPsd"></p>

</div>
<hr/>

<p id="status"></p>
<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-arrow-left">Back</button>
<button type="submit" name="submit" id="loginButton" class="btn btn-primary"><span class="glyphicon glyphicon-lock">Login</button>
<p><br/></p>
<p id="notice"> If not registered yet</p><br/>
<button type="button" id="SignUp" class="btn btn-danger">SingUp</button>

</form>

这是 jQuery 代码:

$(document).ready(function(){

$("#loginButton").click(function(e){
email=$("#exampleInputEmail1").val();
e.preventDefault();
password=$("#exampleInputPassword1").val();
$.ajax({
type: "POST",
url: "StudentLogin.php",
data: "email="+email+"&password="+password,

success:function(html)
{
if(html==true){
---> this function is not working while I am login with correct data
window.location="studentDashBoard.php";
}
else{
$("#status").html("<p>worng id or psd</p>");
}
}
});
});
});

StudentLogin.php代码

<?php
$link = mysqli_connect('localhost','root','','users');
if (!$link) {
die('Could not connect to MySQL: ' . mysqli_error($link));
}

if(isset($_POST['submit']))
{
echo "submit";
$email=$_POST['email'];

$password=$_POST['password'];

$sql = "SELECT * FROM student WHERE email='$email' AND password='$password' ";

$query = mysqli_query($link,$sql);

$result= mysqli_num_rows($query);

if($result > 0)
{
echo 'true';
}
else
{
echo 'false';
}
}

mysqli_close($link);
?>

studentDashBoard.php 文件只是打印“hi”,没有别的。

如果您需要更多详细信息,请告诉我

最佳答案

代替: if(isset($_POST['submit'])){
studentLogin.php 文件中,我更改为

if(isset($_POST['email']) && isset($_POST['password']) )
{
现在可以了

关于php - if(html==true) 不满足这个条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30944822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com