Connecting Tech Pros Worldwide Forums | Help | Site Map

user authentication with SESSION and FORGOT PASSWORD script

Newbie
 
Join Date: Sep 2007
Posts: 17
#1: Nov 12 '07
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

Expand|Select|Wrap|Line Numbers
  1. <!doctype html public "-//w3c//dtd html 3.2//en">
  2.  
  3. <html>
  4.  
  5. <head>
  6.  
  7.  
  8. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  9.  
  10. <table border='0' width='50%' cellspacing='0' cellpadding='0' align=center><form name=form1 method=post action=signupck.php onsubmit='return validate(this)'><input type=hidden name=todo value=post>
  11.  
  12. <tr bgcolor='#f1f1f1'><td align=center colspan=2><font face='Verdana' size='2' ><b>Signup</b></td></tr>
  13. <tr ><td >&nbsp;<font face='Verdana' size='2' >Username</td><td ><font face='Verdana' size='2'><input type=text name=username></td></tr>
  14.  
  15. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Password</td><td ><font face='Verdana' size='2'><input type=text name=password></td></tr>
  16. <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>
  17.  
  18.  
  19. <tr bgcolor='#f1f1f1'><td ><font face='Verdana' size='2' >&nbsp;First Name</td><td  ><input type=text name=f_name></td></tr>
  20. <tr ><td >&nbsp;<font face='Verdana' size='2' >Sirname</td><td ><font face='Verdana' size='2'><input type=text name=l_name></td></tr>
  21.  
  22. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Email</td><td ><font face='Verdana' size='2'>  <input type=text name=email</td></tr>
  23.  
  24. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Address 1</td><td ><font face='Verdana' size='2'>  <input type=text name=address1</td></tr>
  25. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Address 2</td><td ><font face='Verdana' size='2'>  <input type=text name=address2</td></tr>
  26. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >County</td><td ><font face='Verdana' size='2'>  <input type=text name=county</td></tr>
  27. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Post Code</td><td ><font face='Verdana' size='2'>  <input type=text name=postcode</td></tr>
  28. <tr bgcolor='#f1f1f1'><td >&nbsp;<font face='Verdana' size='2' >Telephone Number</td><td ><font face='Verdana' size='2'>  <input type=text name=number</td></tr>
  29.  
  30. <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>
  31.  
  32. <tr bgcolor='#f1f1f1'><td align=center colspan=2><input type=submit value=Signup></td></tr>
  33. </table>
  34.  
  35. <center>
  36. <br><br><font face='Verdana' size='2' ><a href='login.html'>Already a member ? Please Login</a></font></center> 
  37.  
  38.  
  39. <center>
  40. <br><br><font face='Verdana' size='2' ><a href='#'>link</a></font></center> 
  41.  
  42. </body>
  43.  
  44. </html>
  45.  
  46.  
AND THIS CHECKS THE ABOVE


Expand|Select|Wrap|Line Numbers
  1. <?
  2. include "connection.inc.php";// database connection details stored here
  3. ?>
  4. <!doctype html public "-//w3c//dtd html 3.2//en">
  5.  
  6. <html>
  7.  
  8. <head>
  9. <title>(Type a title for your page here)</title>
  10. </head>
  11.  
  12. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  13. <?
  14. if(isset($todo) and $todo=="post"){
  15.  
  16. $status = "OK";
  17. $msg="";
  18.  
  19. // if userid is less than 3 char then status is not ok
  20. if(!isset($username) or strlen($username) <3){$msg=$msg.'Username should be =3 or more than 3 char length<BR>';
  21. $status= "NOTOK";}                    
  22.  
  23.  
  24.  
  25. if(mysql_num_rows(mysql_query("SELECT username FROM auth_users WHERE username = '$username'"))){
  26. $msg=$msg.'Userid already exists. Please try another one<BR>';
  27. $status= "NOTOK";}                    
  28.  
  29.  
  30.  
  31. if ( strlen($password) < 3 ){
  32. $msg=$msg.'Password must be more than 3 char legth<BR>';
  33. $status= "NOTOK";}                    
  34.  
  35.  
  36. if ( $password <> $password2 ){
  37. $msg=$msg.'Both passwords are not matching<BR>';
  38. $status= "NOTOK";}                    
  39.  
  40.  
  41.  
  42. if ($agree<>"yes") {
  43. $msg=$msg.'You must agree to terms and conditions<BR>';
  44. $status= "NOTOK";}    
  45.  
  46.  
  47.  
  48. if($status="NOTOK"){ 
  49. echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
  50. }else{ // if all validations are passed.
  51. $query=mysql_query("insert into auth_users(f_name,l_name,email,username,password,address1,address2,county,postcode,number) values('f_name','$l_name','$email','$username','$password','$address1','$address2','$county','$postcode','$number')");
  52. echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up<br><br><a href=login.php>Click here to login</a><br></font>";
  53. }
  54. }
  55. ?>
  56. <center>
  57. <br><br><a href='#'>#</a></center> 
  58.  
  59. </body>
  60.  
  61. </html>
  62.  

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,755
#2: Nov 12 '07

re: user authentication with SESSION and FORGOT PASSWORD script


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.
Newbie
 
Join Date: Sep 2007
Posts: 17
#3: Nov 13 '07

re: user authentication with SESSION and FORGOT PASSWORD script


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
Reply