Patrick’s development blog

12 Responses

Subscribe to comments with RSS.

  1. dblackshell said, on May 3, 2008 at 2:33 pm

    sorry to mention it but there is a small error in your script… (not in the php part), you created the table user and later used the table loginscript…

  2. patrickbe said, on May 3, 2008 at 11:53 pm

    dblackshell:
    Yes indeed, i’ll edit the code. Thanks for telling.

  3. lebowski said, on July 19, 2008 at 12:02 am

    Nice article.

  4. Shizam said, on July 31, 2008 at 7:55 am

    Hey, great article, but quick quetion. In you login.php dont you need the mysql_close command?

  5. patrickbe said, on July 31, 2008 at 12:09 pm

    Using mysql_close() isn’t really necessary because the links are closed automatically. Everything in PHP except persistent database connections are destroyed by the garbage collector.

  6. Arun Sharma said, on October 1, 2008 at 4:48 am

    Sir,

    You told about security risk in password field mentioning ‘ OR ” = ‘ . I want to know how a person can be registered on any registeration site wthout a password. If he isn’t get registered then there is no any question that he will login without use of password using ‘ OR ” = ‘ (thats mean username whatever he enters and password field blank). Please clear my doubt…..

    with regards,
    Arun Sharma
    Project Assistant Level – II,
    IMTECH, Chandigarh, Haryana, India.

  7. patrickbe said, on October 2, 2008 at 7:49 pm

    It’s not like the password is empty. It’s more like you are tricking the login script to believe that it’s the correct password. If we for example add the following string as a password:

    ‘ or ” = ‘

    The SQL-query would then look something like this (supposing we provided the user username):

    (SELECT blabla FROM users WHERE user = ‘username’ AND password = ‘ ‘ or ‘ ‘ = ‘ ‘ “)

    If I remember correctly, it’ll always be true. The password itself stored in the database can be anything though. We’re not actually changing the password but the SQL-query that checks if the password is correct.

  8. johnr said, on November 22, 2008 at 1:52 pm

    Would it not be simpler to fetch the user account details by username only and then compare the (hopefully hashed) passwords in code? This would avoid any risk of the SQL injection returning a false positive.

    Even if the user passed some rubbish SQL in the username field, they must still provide a valid password to match whatever user account record is found by the SQL query in order to be granted access.

  9. Jamal Ahmad Malik said, on November 25, 2008 at 10:31 am

    You can get rid of PHP headers problem through following code of java Script , i am using this function for last 5 years in PHP programming and working great.

    <?
    function Redirect($URL)
    {
    print
    (”

    location.href = ‘$URL’;

    “);

    }
    ?>

    Redirect(“yourpage.php”);

    You can find and discuss same kind of ready made functions on this website blog
    http://www.exploremyblog.com

  10. Wellbutrin said, on November 27, 2008 at 9:22 pm

    Good pages and design! Thanks webmaster!

  11. yuvaraj said, on January 12, 2010 at 5:58 am

    hi….tat code was some wat helpfull for me.. thank u…. give me a link back… and your valuable comments .

  12. Nirmal Kumar said, on December 22, 2010 at 3:30 am

    wow !! its best


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: