我输入了正确的用户名和密码,但是我的登录页面没有响应第一次尝试:尽管确实是第二次尝试,但它仍然响应。
我的登录页面为 login.php ,登录页面为 index.php
这是我的html:
net2
这是我的php代码
<form method="post" >
<input type="text" name="email" class="form-control" placeholder="Username" required />
<input type="password" name="password" class="form-control" placeholder="Password" required />
<button class="btn btn-default submit" >Log In</button>
</form>
答案 0 :(得分:0)
尝试使用这个。
您的HTML代码:
<form method="post" >
<input type="text" name="email" class="form-control" placeholder="Username" required />
<input type="password" name="password" class="form-control" placeholder="Password" required />
<button name="submit" class="btn btn-default submit" >Log In</button>
</form>
以及您的PHP代码:
if(isset($_POST['submit'])){
$email=$_POST["email"];
$password=$_POST["password"];
//do form validation here
$sql="SELECT * FROM user_registration WHERE email='{$email}' AND password='{$password}'";
$res=mysqli_query($con,$sql);
if (mysqli_num_rows($res)==1)
{
$row=mysqli_fetch_assoc($res);
$_SESSION["name"] =$row['email'];
$_SESSION['user_name']=$row['user_name'];
$_SESSION['user_id']=$row['id'];
$_SESSION["login_status"] =TRUE;
header("Location: index.php");
}else{
$msg="Wrong Username and Password";
header("Refresh:0");
}
}
}
如果您有帮助,请告诉我。