Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

PHP Tutorials: Register & Login: User login (Part 2)

Loading...

Sign in or sign up now!
149,499
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Feb 11, 2009

Part of the 'Register & Login' Project from PHP Academy. This tutorials walks you through how to process a username and password based login against details found in a database, set a session, and process a logout function.

Link to this comment:

Share to:

Top Comments

  • I hate youtube ads!!!! im trying to learn :(

  • This is the full working code for this tutorial. Part I

    <?php

    $username = $_POST['username'];

    $password =$_POST['password'];

    if ($username&&$password)

    { $connect = mysql_connect("localhost","roo­t","") or die ("cannot connect to the database"); mysql_select_db("phpalex") or die("Couldn't find db"); $query = mysql_query("SELECT * FROM user1 WHERE username='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) {

see all

All Comments (496)

Sign In or Sign Up now to post a comment!
  • This way has a MASSIVE security risk of SQL injections. Imagine this input for username/password:

    '; DROP TABLE users; --

    This would fail to log them in BUT delete all users in the table users.

    You should add this before running it through the database:

    $username = mysql_real_escape_string($user­name);

    $password = mysql_real_escape_string($pass­word);

    I know, it's not basic, but one should know dangers of SQL injections. It would also be good to md5 or sha1 all passwords. *complicates everything*

  • why at 5:23 i get this error Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\XAMPP\htdocs\website\login.­php on line 13

    That user doesn't exist!

  • i was getting wrong password error, so i started over, and for some reason it work.............started over back from tutorial part 1 and it works,

  • The 1 is not appearing on my screen nothing happened like before

  • @fruitman89 hahahaha i agree

  • hey can you tell me how to transfer data from one page to multiple pages?

    ID from page1 to page2 to page3 and goes on........

  • @onebighoe Just install adblock plus.

  • rihanna's ass keeps distracting me!!

  • @onebighoe Learn to bypass, fucking.

View all Comments »
Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more