37 thoughts on “How to Code PHP: Login and Forgotten Password Scripts”

  1. Great day guys.. could you help me out with the script that if you want to reset your password..a link would be sent to your email before password would be reset..thanks in advance 🙂

  2. thanks, i used the forgot password code but there is error message as follow :
    Fatal error: Call to undefined function escape_data() in /home/fuvuxco/public_html/member_login_-gffdfdsew3245678ueygdtrefscxdxaswertyuijfndgdffe-0-_ueyetd54vdfdre5syd/forgortpw.php on line 35

    please what shoul i do

  3. Hi:

    Below is the problem I am having, and I need your help.

    I have been testing my work by filling out the membership registration form using my own Web site.

    I do not know why the password I entered and the one in my database do not match.

    Therefore, when I test my work again by filling out the “forgotten password” form, I got an email showing the different password.

    I have read somewhere about this, and I do not know if it is true and how to fix it.

    An article I have read says that it is because the password field is set as VARCHAR (32) and Mb5 is used.

    I would appreciate any help you may offer.

    1. Thank you very much 🙂 Yes, I’m going to revisit PHP because I think the tutorial could be vastly improved. This was one of my first big tutorials. I need to cover PHP frameworks among many other topics. Feel free to leave requests

      1. frameworks would be a great idea. More advanced php security for mysql would prob be my only main request. You can never have enough of it. Agian ty so much for your time and sharing your knowledge with us. It is refreshing to finally find someone with the ability to explain things in a down to earth way that makes it easy to understand. I tip my hat to you sir.

  4. Would you consider looking at a site for possible security flaws. I am a trying to dive deeper into coding and at least what to see if I’m going in the right path. As you are at this point “A php god” I thought I’d at least ask. It is no problem if you decline. Still love your work. Ty again

    1. Thank you for the complement 🙂 I don’t consider myself a PHP God, but I guess I’m ok. I should have covered frameworks in my PHP tutorial and I’ll definitely do that very soon.

      Sadly I can’t run any tests on your site because it may be perceived as an attack that could get me into a lot of trouble. I can however show you the most common ways sites are attacked. Look at my PHP Security tutorial.

      In the PHP security tutorial I show you how all of the following attacks work:
      SQL Injection
      Cross Site Scripting (XSS)
      Malicious Code Encoding
      Session Hijacking
      Session Fixation
      Malicious System Calls
      Buffer Overflows

      I hope that helps – Derek

      1. I understand your concerns and will respect them. I am looking over your videos and learning much from them. Thanks for the options.

  5. quick question if I may. how do you feel about FILTER_SANITIZE_STRING for validation and security? Do you recommend it? Also PDO connecting to database?

    1. Yes, I use FILTER_SANITIZE_STRING now. I also plan to cover PDO in the future. PHP framework tutorials are also in the works. Thank you for the requests 🙂

  6. hi can i ask how do i solve the problem for the function, mail(). It says that it fails to connect to mailserver.

  7. Hi Derek your work from 3 years ago still doesnt get out of date! You did a great job, writing all these steps and putting in all this effort.
    I have a website with 4 other people. Our password reset system works so far and also the registration process althoug it was developed not with the help of this guidline. The truth is I’m unsatisfied and would like to improve the procedure.
    I would like to change the registration process of our website in a way that you can set your password directly when you create an account, e.g. like Facebook.
    Also I really like that mostly all services offer now that when you reset your password, they send you a mail with a form where you can set your new password directly without this extra step of a temporary code. Also if this doesnt work the Reset-Mail offers you a link with a form where you have to enter and reenter a new password which will be set.
    I really would like to have this way of reseting passwords because its faster and way more convenient. This way you avoid the following step completely: when the person gets the temporary password and doesn’t decide to cange it to someting more memorable right away, next time he will have the same problem again, and reset the password again and use the new temporary password again in case s/he wouldn’t the old temporary password can not be found.
    Thanks in advance!!!
    Alex

    1. Thank you very much 🙂 I’m definitely going to cover PHP again in the future. I’m not particularly happy with this current tutorial now. I much prefer the complete coverage I have been able to achieve with my java tutorials. I get to the requests as soon as possible

  8. Hello, I really like the you demostrate the scripts ! Good Job.
    Quick question, is there any tutorial for Change the password ? 😛

    1. Thank you 🙂 I decided that the easiest thing to do to allow the person to change their password was to say they forgot it. This script could be used as a change the password script as well. I want to update this information very soon when I cover Zend.

  9. Hey Derek, I’ve been a fan of your tutorial videos for a while now, and just wanted to let you know that for the phrase “php reset user password” this article made front page results on google! (tested it on a browser I rarely use just to double check and still front page).

    It would be awesome if you could do a ‘PHP revisited’ series that really digs deep into the native functions PHP has to offer…just planting the bug in your ear 😛

    1. That is very cool. Google normally doesn’t rank my site very well. Yes I’m going to cover PHP and the Zend framework very soon because I need it to set up web services for my Android tutorial. i’ll get to it asap

Leave a Reply

Your email address will not be published. Required fields are marked *