[英]Why this PHP code if else condition is not working?
在if (!empty) {}
部分之后检查 IF ELSE 语句。
<form action="first.php" method ="post">
<input type="text" name="username" >Username</br>
<input type="password" name="password" >Password</br>
<input type="submit" value="Submit"></br>
</form>
<?php
if (isset($_POST['username'] )&& isset($_POST['password'])) {
if (!empty($user) && !empty($pass)) {
$user = $_POST['username'];
$pass = $_POST['password'];
if ($user ==="habib" && $pass === "1234") {
echo $user;
echo $pass;
} else {
echo "wrong password and username";
}
}
}
?>
您需要检查$_POST['username']
和$_POST['password']
是否不为空,而不是$user
和$pass
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.