By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,349 Members | 1,353 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,349 IT Pros & Developers. It's quick & easy.

forget password coding issue

P: 17
Hi All,

The following script works when username(or email) and password are in 1 table. what i need to know is how to adjust the code to reflect that the email will be held in tbl_email and the password will be held in tbl_master_name.

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <?php
  4. include ("conn.inc.php");
  5.  
  6. $username=$_POST["username"];
  7. $res=mysql_query("SELECT username, email FROM tbl_master_name, tbl_email WHERE username='$username'") or die("cannot select from email");                
  8. $row=mysql_fetch_array($res);
  9. $email=$row["email"];
  10. srand((double)microtime()*1000000);  
  11. $random=rand(1234,2343); 
  12. $password=$row["name"].$random; 
  13.  
  14. $upassword=md5($password);
  15.  
  16. mysql_query("update tbl_master_name set password='$password' where username='$username'") or die("cannot send your password");
  17.  
  18. $headers ="From: noreply@ACRE.com\n"; //from address
  19. $headers .= "MIME-Version: 1.0\n";
  20. $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
  21. $subject ="Password Recovery - Do Not Reply Back To This Email";
  22.  
  23. $body="<div align=center><br><br>----------------------------- A.C.R.E Password Recovery--------------------------------<br><br><br><br>
  24. Your Temporary Password is: $password<br><br>Remember your password this time or the cow gets it!<br><br><br>Click the link below to log in. <br>http://www.tramp-space.co.uk/assignment/ <br><br> If the link doesnt work, please copy it and paste it into your browser.<br><br> Thank you</div>";
  25.  
  26. if(mail($email,$subject,$body,$headers)) {echo "<font class=tblackb>Your password has been send to your Registered Email</font> ";}  
  27.  
  28. else {echo "<font class=tblackb>Password Not Send.<br><Br>Please Try Again Later!...</font>";}
  29. ?>
  30.  
  31.  
Feb 11 '08 #1
Share this Question
Share on Google+
2 Replies


ronverdonk
Expert 2.5K+
P: 4,258
O don't see the problem. You already get the 2 columns for userid and email address from 2 tables: tbl_master_name and tbl_email.

Maybe I misunderstand, but please elaborate a bit.

Ronald
Feb 11 '08 #2

P: 17
i have email in tbl_email and the password in tbl_master_name.

The mysql statement should work as:

SELECT email, password FROM tbl_email, tbl_master_name
WHERE email='$email;

If you look on line 16, you will find the error message i am recieving, which im sure is whre the problem is
Feb 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.