==, 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 ""; }
//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'";
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
reply==, 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.
reply<?php
session_start();
//Login processing interface logincheck.php
//Determine whether the submit button is pressed
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. After confirmation, return to the previous page of the current page.
echo "<script>alert('Please enter your username or password!'); history.go(-1);</script>";
}
else
{ //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
if(mysqli_errno($conn)){
echo mysqli_errno($conn);
exit;
}
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 "<script>alert('Successfully logged in'); window.location.href='index.php';</script>";
}
else
{
echo "<script>alert('Username or password is incorrect!');history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('Submission failed!');</script>";
}
?>
-------------------------------------------------- -------
Hehe, can you add WeChat to ask for advice? Mine is 289810491
reply<?php
session_start();
//Login processing interface logincheck.php
//Determine whether the submit button is pressed
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. After confirmation, return to the previous page of the current page.
echo "<script>alert('Please enter your username or password!'); history.go(-1);</script>";
}
else
{ //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
if(mysqli_errno($conn)){
echo mysqli_errno($conn);
exit;
}
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 "<script>alert('Login successfully'); window.location.href='index.php';</script>";
}
else
{
echo "<script>alert('Username or password is incorrect!');history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('Submission failed!');</script>";
}
?>
-------------------------------------------------- -------
Hehe, can you add WeChat to ask for advice? Mine is 289810491
==, 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 ""; }
<?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!
Where is your code?,,,,,
? ? ? ? Post the page picture