我已经为服装网站创建了一个登录表单。我已经使用了isset()函数和按钮上的if语句单击说如果单击按钮...执行此操作....但是,当我在浏览器上运行时(我使用xammp作为我的本地主机),页面工作正常但是当我输入凭据并按下提交按钮时,它不会重定向到下一页,或者甚至没有回显“登录成功”或“登录失败。我在php中使用了错误报告功能来跟踪错误但它没有显示任何错误无论是。 这是我的代码
IndexLogin.html
<html lang="en">
<head>
<title>Login </title>
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form">
<form method="POST" form action="login.php">
<span class="login100-form-title p-b-34">
SHAARANYA~<br>
Account Login
</span>
<div class="wrap-input100 rs1-wrap-input100 validate-input
m-b-20" data-validate="Type email">
<input id="email" class="input100" type="text"
name="email" placeholder="email" >
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 rs2-wrap-input100 validate-input
m-b-20" data-validate="Type password">
<input class="input100" type="password" name="pass"
placeholder="Password" >
<span class="focus-input100"></span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn"
button type="submit" name="submit">
Sign in
</button>
</div>
<div class="w-full text-center p-t-27 p-b-239">
<span class="txt1">
Forgot
</span>
<a href="#" class="txt2">
User name / password?
</a>
<br>
<br>
<p><font size="3">Not a Member Yet? Join us for FREE!
<br><br><a href="#"><b> SIGN UP </font></b> </a></p>
</div>
</form>
</body>
</html>
的login.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$servername = "localhost";
$username = root;
$password = "";
$dbname="company";
$conn = new mysqli($servername,$username,$password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_POST['submit'])){
$email=$_POST['email'];
$pass=$_POST['pass'];
$sql = "SELECT * FROM login WHERE email = '".$email."' and pass =
'".$pass."'";
$result = mysqli_query( $conn,$sql);
if(mysql_num_rows($result)==1){
echo "Login Successful";
}
else {
echo "Failed To Login";
}
}
?>
答案 0 :(得分:1)
我已经清理了你的HTML脚本。请现在试试,希望这对你有用。
<html lang="en">
<head>
<title>Login</title>
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form method="POST" form action="login.php">
<span class="login100-form-title p-b-34">
SHAARANYA~<br>
Account Login
</span>
<div class="wrap-input100 rs1-wrap-input100 validate-input
m-b-20" data-validate="Type email">
<input id="email" class="input100" type="text"
name="email" placeholder="email" >
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 rs2-wrap-input100 validate-input
m-b-20" data-validate="Type password">
<input class="input100" type="password" name="pass"
placeholder="Password" >
<span class="focus-input100"></span>
</div>
<div class="container-login100-form-btn">
<button class="login100-form-btn" type="submit" name="submit">
Sign in
</button>
</div>
<div class="w-full text-center p-t-27 p-b-239">
<span class="txt1">
Forgot
</span>
<a href="#" class="txt2">
User name / password?
</a>
<br>
<br>
<p><font size="3">Not a Member Yet? Join us for FREE!
<br><br><a href="#"><b> SIGN UP </font></b> </a></p>
</div>
</form>
</body>
</html>