The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Help with PHP Login

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #41858

    Hello css-tricks community.

    I am trying to work on a little area for a website where the administrator can login and update a php table that offers 3 services. I have the php table working and updating properly. However when I did the login page. My page will not redirect to the page that I select. I used the [phpeasy steps login tutorial] but I cannot figure out why it is not working. I can get get it to tell me if the user name and password is wrong and also I can successfully sign out. Is there another tutorial I could use, or could you suggest what is wrong with my code. I studying php and I am trying to learn what is wrong with it. Any help will be greatly appreciated!!!** Thank you in advance!**
    This is for the login page
    [codepen for login page…]( “Code Pen for login”)

    This is for the login action php:

    // Connect to server and select databse.
    mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
    mysql_select_db(“$db_name”)or die(“cannot select DB”);

    // Define $myusername and $mypassword

    // To protect MySQL injection (more detail about MySQL injection)
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);
    $sql=”SELECT * FROM $tbl_name WHERE username=’$myusername’ and password=’$mypassword'”;

    // Mysql_num_row is counting table row

    // If result matched $myusername and $mypassword, table row must be 1 row

    // Register $myusername, $mypassword and redirect to file “login_success.php”
    else {
    echo “Wrong Username or Password”;



    Something I noticed in your example code…

    This comment has “login_success.php”

    // Register $myusername, $mypassword and redirect to file “login_success.php”

    But this line has “success_login.php”


    Could this be the issue?


    Thank you so much for your response hotpink! I will do that and look at it and see if it is the problem. Thank you for taking time to check the code for me =) I really appreciate it


    I just checked and that is not it =(.


    I wouldn’t recommend using mysql_connect for your login. You would be much better off using PDO. Here’s a tutorial on how to use it:

    [PDO tutorial]( “PDO tutorial”)

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.