search

Home  >  Q&A  >  body text

Please tell me why the login page written according to this code shows that the submission was unsuccessful.

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

皮安乐皮安乐2369 days ago1688

reply all(7)I'll reply

  • 朝游东海

    朝游东海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 ""; }

    reply
    0
  • 皮安乐

    皮安乐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!

    reply
    0
  • 朝游东海

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

    朝游东海 · 2018-06-05 14:30:43
  • 朝游东海

    朝游东海2018-06-04 17:19:02

    Where is your code?,,,,,

    reply
    1
  • 皮安乐

    <?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

    皮安乐 · 2018-06-04 17:47:54
    皮安乐

    Can you leave me your contact information?

    皮安乐 · 2018-06-04 20:31:30
  • 往事随云走

    往事随云走2018-06-04 10:59:12

    ? ? ? ? Post the page picture

    reply
    1
  • 皮安乐

    <?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

    皮安乐 · 2018-06-04 17:46:36
  • Cancelreply