1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP I want PHP code login and registaring form.can Anybody help me ?

Discussion in 'Web Development' started by Advait 007, Apr 7, 2014.

  1. Advait 007

    Advait 007 New Member

    I want to make a login and Registration form for my website.but I new in PHP.so,that anybody will give the code ?
     
  2. Gonzoide

    Gonzoide New Member

    Do you already have a MySQL / PHP website to start with ?

    If so, a simple table defining user and code should do the trick : the idea is that you shouldn't need to store the password in clear, but an encrypted form.

    You create a simple html form to input userid/password :

    <form action="valid.php" method='post'>
    <p>Login : <br/><input type="text" name="login" maxlength="250"/></p>
    <p>Password :<br/><input type="password" name="pass" maxlength="15"/></p>
    <p><input type="submit" value="Validate"/></p>
    </form>


    In your valid.php file, you load the details of your user, and check that the password you received is the same as the one you stored. Of course you don't work on clear passwords, but encrypted copies ... md5 + salt makes the trick for a low-but-acceptable level of protection :

    $salt1 = "$รน')(=#;
    $slat2 = "#=}&";

    $rs = executeSQL("select u.password, u.md5, u.first_name, u.last_name, u.user_id from user u, level l where login='".$login."');
    $data = getData($rs);

    if($data['md5'] == md5($salt1.$pass.$salt2)) {
    // user is valid
    }


    Pros:

    Password is never stored in readable way, reducing the risk of massive theft of passwords

    Cons:
    Since even the webmaster himself has no way to retrieve the password, if your user lose it you'll have to reset it as you won't be able to give it back

    This is the pattern I'm using on my website for safety reasons, some may consider this is too much, up to you.



     
    Dawn likes this.