在php表单提交中未调用操作文件。我发现发生了同样的问题here,但是没有正确的答案。
以下是代码
index.php
<form action="form_submit.php" method="POST" class="form-group">
<div>
<label>Email address</label>
<input type="email" name="login_email" class="form-control" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" name="login_pw" class="form-control" id="InputPassword1" placeholder="Password">
</div>
<button type="submit" name="submit" value="submit" class="btn btn-primary"><i class ="fa fa-lock"> </i>Submit</button>
</form>
form_submit.php
<?php
echo "entered";
$con=mysqli_connect("localhost","root","","inventory");
if(isset($_POST['submit']) && $_SERVER["REQUEST_METHOD"] == "POST"){
$username=$_POST['login_email'];
$password=$_POST['login_pw'];
$query="select * from userlogin where username='$username' and password='$password'";
$result=mysqli_query($con,$query);
if(mysqli_num_rows($result)==1)
{
header("location:hello.php");
}
else
{
echo"<script>alert('wrong password or user name if you lost your password please contact service provider')</script>";
echo"<script>window.open('index.php','_self')</script>";
}
}
?>
至少没有显示echo
顶部的form_submit.php
。我试图将提交代码放在index.php
的顶部,并尝试了自调用action=""
。甚至没有用。
答案 0 :(得分:0)
删除此行,因为验证错误后,它将进入index.php页面
echo"<script>window.open('index.php','_self')</script>"; from