Please tell me why the login page written according to this code shows that the submission was unsuccessful.
皮安乐
皮安乐 2018-06-03 10:48:14
0
7
1671

Excuse me, why does the login page written according to this code show that the submission was unsuccessful

皮安乐
皮安乐

reply all(4)
北方

==, 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!

  • 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.
    朝游东海 author 2018-06-05 14:30:43
北方

Where is your code?,,,,,

  • reply &lt;?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 "&lt;script&gt;alert('Please enter your username or password!'); history.go(-1);&lt;/script&gt;"; } 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 "&lt;script&gt;alert('Successfully logged in'); window.location.href='index.php';&lt;/script&gt;"; } else { echo "&lt;script&gt;alert('Username or password is incorrect!');history.go(-1);&lt;/script&gt;"; } } } else { echo "&lt;script&gt;alert('Submission failed!');&lt;/script&gt;"; } ?&gt; -------------------------------------------------- ------- Hehe, can you add WeChat to ask for advice? Mine is 289810491
    皮安乐 author 2018-06-04 17:47:54
  • reply Can you leave me your contact information?
    皮安乐 author 2018-06-04 20:31:30
往事随云走

? ? ? ? Post the page picture

  • reply &lt;?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 "&lt;script&gt;alert('Please enter your username or password!'); history.go(-1);&lt;/script&gt;"; } 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 "&lt;script&gt;alert('Login successfully'); window.location.href='index.php';&lt;/script&gt;"; } else { echo "&lt;script&gt;alert('Username or password is incorrect!');history.go(-1);&lt;/script&gt;"; } } } else { echo "&lt;script&gt;alert('Submission failed!');&lt;/script&gt;"; } ?&gt; -------------------------------------------------- ------- Hehe, can you add WeChat to ask for advice? Mine is 289810491
    皮安乐 author 2018-06-04 17:46:36
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template