user authentication with SESSION and FORGOT PASSWORD script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whitey
    New Member
    • Sep 2007
    • 17

    user authentication with SESSION and FORGOT PASSWORD script

    Can anybody supply me with a script the does what is in the title above please?

    I have tried so many different methods!

    here is what im currently trying to get to work

    SIGN IN

    [code=html]
    <!doctype html public "-//w3c//dtd html 3.2//en">

    <html>

    <head>


    <body bgcolor="#fffff f" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" >

    <table border='0' width='50%' cellspacing='0' cellpadding='0' align=center><f orm name=form1 method=post action=signupck .php onsubmit='retur n validate(this)' ><input type=hidden name=todo value=post>

    <tr bgcolor='#f1f1f 1'><td align=center colspan=2><font face='Verdana' size='2' ><b>Signup</b></td></tr>
    <tr ><td >&nbsp;<font face='Verdana' size='2' >Username</td><td ><font face='Verdana' size='2'><input type=text name=username></td></tr>

    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Password</td><td ><font face='Verdana' size='2'><input type=text name=password></td></tr>
    <tr ><td >&nbsp;<font face='Verdana' size='2' >Re-enter Password</td><td ><font face='Verdana' size='2'><input type=text name=password2> </td></tr>


    <tr bgcolor='#f1f1f 1'><td ><font face='Verdana' size='2' >&nbsp;First Name</td><td ><input type=text name=f_name></td></tr>
    <tr ><td >&nbsp;<font face='Verdana' size='2' >Sirname</td><td ><font face='Verdana' size='2'><input type=text name=l_name></td></tr>

    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Email</td><td ><font face='Verdana' size='2'> <input type=text name=email</td></tr>

    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Address 1</td><td ><font face='Verdana' size='2'> <input type=text name=address1</td></tr>
    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Address 2</td><td ><font face='Verdana' size='2'> <input type=text name=address2</td></tr>
    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >County</td><td ><font face='Verdana' size='2'> <input type=text name=county</td></tr>
    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Post Code</td><td ><font face='Verdana' size='2'> <input type=text name=postcode</td></tr>
    <tr bgcolor='#f1f1f 1'><td >&nbsp;<font face='Verdana' size='2' >Telephone Number</td><td ><font face='Verdana' size='2'> <input type=text name=number</td></tr>

    <tr ><td >&nbsp;<font face='Verdana' size='2' >I agree to terms and conditions</td><td ><font face='Verdana' size='2'><input type=checkbox name=agree value='yes'></td></tr>

    <tr bgcolor='#f1f1f 1'><td align=center colspan=2><inpu t type=submit value=Signup></td></tr>
    </table>

    <center>
    <br><br><font face='Verdana' size='2' ><a href='login.htm l'>Already a member ? Please Login</a></font></center>


    <center>
    <br><br><font face='Verdana' size='2' ><a href='#'>link</a></font></center>

    </body>

    </html>

    [/code]

    AND THIS CHECKS THE ABOVE


    [code=php]
    <?
    include "connection.inc .php";// database connection details stored here
    ?>
    <!doctype html public "-//w3c//dtd html 3.2//en">

    <html>

    <head>
    <title>(Type a title for your page here)</title>
    </head>

    <body bgcolor="#fffff f" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" >
    <?
    if(isset($todo) and $todo=="post"){

    $status = "OK";
    $msg="";

    // if userid is less than 3 char then status is not ok
    if(!isset($user name) or strlen($usernam e) <3){$msg=$msg.' Username should be =3 or more than 3 char length<BR>';
    $status= "NOTOK";}



    if(mysql_num_ro ws(mysql_query( "SELECT username FROM auth_users WHERE username = '$username'"))) {
    $msg=$msg.'User id already exists. Please try another one<BR>';
    $status= "NOTOK";}



    if ( strlen($passwor d) < 3 ){
    $msg=$msg.'Pass word must be more than 3 char legth<BR>';
    $status= "NOTOK";}


    if ( $password <> $password2 ){
    $msg=$msg.'Both passwords are not matching<BR>';
    $status= "NOTOK";}



    if ($agree<>"yes") {
    $msg=$msg.'You must agree to terms and conditions<BR>' ;
    $status= "NOTOK";}



    if($status="NOT OK"){
    echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='histor y.go(-1)'>";
    }else{ // if all validations are passed.
    $query=mysql_qu ery("insert into auth_users(f_na me,l_name,email ,username,passw ord,address1,ad dress2,county,p ostcode,number) values('f_name' ,'$l_name','$em ail','$username ','$password',' $address1','$ad dress2','$count y','$postcode', '$number')");
    echo "<font face='Verdana' size='2' color=green>Wel come, You have successfully signed up<br><br><a href=login.php> Click here to login</a><br></font>";
    }
    }
    ?>
    <center>
    <br><br><a href='#'>#</a></center>

    </body>

    </html>
    [/code]
    Last edited by Atli; Nov 12 '07, 12:21 PM. Reason: Changed [code] tags to [code=php].
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    We are happy to help you out if you run into any problems while writing your code, but we will not write it for you. Check out the Posting Guidelines for more info on this.

    If you run into any problems while writing the code, post it here and we will do our best to help you out.

    As to the code you posted.
    What exactly is the code supposed to do?
    Why (how) is it not working?

    You can check out this article for an example of how to use Sessions to handle user logins.

    Comment

    • whitey
      New Member
      • Sep 2007
      • 17

      #3
      Hi,

      That is no problem at all, i wouldnt expect it to be done for me.

      The first piece of code simply is for registering an account

      the second piece of code checks everything is ok with what has been entered before submitting. When i run it, it just writes the code to the screen. No issues with first piece as it is posting fine

      Comment

      Working...