forget password coding issue

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

    forget password coding issue

    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 .

    Code:
    
    <?php
    include ("conn.inc.php");
    
    $username=$_POST["username"];
    $res=mysql_query("SELECT username, email FROM tbl_master_name, tbl_email WHERE username='$username'") or die("cannot select from email");				
    $row=mysql_fetch_array($res);
    $email=$row["email"];
    srand((double)microtime()*1000000);  
    $random=rand(1234,2343); 
    $password=$row["name"].$random; 
    
    $upassword=md5($password);
    
    mysql_query("update tbl_master_name set password='$password' where username='$username'") or die("cannot send your password");
    
    $headers ="From: noreply@ACRE.com\n"; //from address
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
    $subject ="Password Recovery - Do Not Reply Back To This Email";
    
    $body="<div align=center><br><br>----------------------------- A.C.R.E Password Recovery--------------------------------<br><br><br><br>
    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>";
    
    if(mail($email,$subject,$body,$headers)) {echo "<font class=tblackb>Your password has been send to your Registered Email</font> ";}  
    
    else {echo "<font class=tblackb>Password Not Send.<br><Br>Please Try Again Later!...</font>";}
    ?>
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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

    Comment

    • whitey
      New Member
      • Sep 2007
      • 17

      #3
      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

      Comment

      Working...