<form name="login" action=""<?php echo $_SERVER['PHP_SELF']; ?>"" method="post" accept-charset="utf-8">
<label for="usermail">Username</label>
<input type="text" name="nume" placeholder="username" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
<?php
$connection = mysqli_connect("127.0.0.1", "root", "", "agentie");
if (isset($_POST["nume"]) && isset($_POST["password"])) {
if (($_POST["nume"] == "admin") && ($_POST["password"] == "admin123")) {
echo "ati intrat in panoul de control";
}
$query1 = mysqli_query($connection, "SELECT user, password FROM user u WHERE u.user='$_POST[nume]'") or die("Error in the consult.." . mysqli_error($connection));
while ($row = mysqli_fetch_assoc($query1)) {
if (($row["user"] == $_POST["nume"]) && ($row["password"] == $_POST["password"]))
echo "Bine ati venit" . $row["user"];
}
}
?>
我不知道为什么我的2个套装永远不会成真。如果我删除if条件,我
它们出现在simply print $_POST["nume"]
和$_POST["password"]
。
提前致谢。
答案 0 :(得分:0)
你的isset工作但是嵌套的if语句不匹配尝试在first if语句中回显它。
if (isset($_POST["nume"]) && isset($_POST["password"])) {
echo $_POST["nume"];
echo $_POST["password"];
if (($_POST["nume"] == "admin") && ($_POST["password"] == "admin123")) {
echo "ati intrat in panoul de control";
}
答案 1 :(得分:0)
<form name="login" method="post" accept-charset="utf-8">
<label for="usermail">Username</label>
<input type="text" name="nume" placeholder="username" required>
<label for="password">Password</label>
<input type="password" name="password" placeholder="password" required>
<input type="submit" value="Login">
</form>
<?php
if (isset($_POST["nume"], $_POST["password"])) {
echo "It works";
if (($_POST["nume"] == "admin") && ($_POST["password"] == "admin123")) {
echo "ati intrat in panoul de control";
}
}
?>
答案 2 :(得分:0)
未评估您的$_POST
变量。
改变这个:
$query1 = mysqli_query($connection, "SELECT user, password FROM user u WHERE u.user='$_POST[nume]'") or die("Error in the consult.." . mysqli_error($connection));
到
$query1 = mysqli_query($connection, "SELECT user, password FROM user u WHERE u.user='{$_POST[nume]}'") or die("Error in the consult.." . mysqli_error($connection));