Excuse me, why does the login page written according to this code show that the submission was unsuccessful
朝游东海2018-06-05 14:33:15
==, boy, you all know that the submission of the prompt is unsuccessful, and then you look at your code, it means that there is no judgment at all, just the first if(isset($_POST["hidden"]) && $_POST["hidden "] == "hidden") There is no entry here, so you can take a look at what you posted if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden"){ }else{ echo ""; }
皮安乐2018-06-04 19:02:20
<?php
session_start();
//Login processing interface logincheck.php
//Determine whether to press the submit button
if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden")
{
//Save username and password into variables , for subsequent use
$user = trim($_POST["username"]);//trim() function removes whitespace characters on both sides of the string
$psw = md5( trim($_POST["userpwd"]));//The password is encrypted once using md5() and stored in the database
if($user == "" || $psw == "")
// If one of the username or password is empty, a dialog box will pop up, and after confirmation, return to the previous page of the current page. ('Please enter your username or password!'); history.go(-1);</script>";
}
Confirm that the username and password verification code is not empty, then connect to the database
$conn = mysqli_connect("localhost", "root", "root");//The database account password is set when installing the database
Mysqli_select_db($conn ,"userdb");
mysqli_set_charset($conn,'utf8');
$sql = "select username,userpwd from user where username = '$user' and userpwd = '$ psw'";
$result = mysqli_query($conn,$sql);
$num = mysqli_num_rows($result);
if($num)
{
Echo "& lt; script & gt; alert ('Successfully log in'); Window.location.href = 'Index.php'; & LT;/Script & GT;";
# } Else { Echo "& LT; Script & GT; Alert ('user name or password is incorrect! ');history.go(-1);</script>";}
}
}
Else
## { Echo "& LT ! ');</script>"; } ?>
#-- -------------------------------------------------- -------------------------------------------------- --------------------
Is the setting of the link database wrong or something? Please give me some advice! I used the mysql that comes with phpstudy without making any changes. I just set the username and password to root.
In addition, trying to change the localhost in $conn = mysqli_connect("localhost","root","root") to localhost/phpMyAdmin or 127.0.0.1 shows that the submission is unsuccessful
Thank you!