Page 1 of 1

Help with my Forgot Password script...

Posted: Sat Jul 06, 2002 7:18 am
by cooler75
Hello,
I have posted this question in other forum too.

Anyways, my question is this, I generated password for my users using PASSWORD (), now i have a forgot password page where users can input their email to have a new password sending to them. I have the UPDATE part done successfully for the script. However, when users receive email they can only see their new password, but their username is blank.

here is the script,..

Code: Select all

$newpass = substr(md5(time()),0,6);

	$sql = "UPDATE mgrs SET mgrpass = PASSWORD('$newpass') WHERE mgremail='$email'";

	mysql_query($sql);  

	$sql = mysql_query("SELECT * FROM mgrs WHERE mgremail='$email'",$link);

	while ($a_row =mysql_fetch_array ($sql) )
		
		{
		
		
    $subject = "Your Login and Password";

		$fromName = $yourname;

		$fromAddres = $youremail;

		$message = "Your login name is: $rowїmgr]\r\nYour password is: $newpass\r\n";



		$temp = mail($email, $subject, $message, "From: ".$fromName." <".$fromAddress.">") or print "Could not send mail.<BR><BR><P>";

		if ($temp = true) &#123;print "Check your email for username and new password<P> ";&#125;


		&#125;
The email received will be something like this:

Code: Select all

Your login name is :
Your password is : 6063ad
The login name is blank...Can somebody look and check my script and let me know what i did wrong here?

thanks a bunch.

...

Posted: Sat Jul 06, 2002 7:33 am
by QWERTY
Try this:

Code: Select all

$newpass = substr(md5(time()),0,6); 

   $sql = "UPDATE mgrs SET mgrpass = PASSWORD('$newpass') WHERE mgremail='$email'"; 

   mysql_query($sql);  

   $sql = mysql_query("SELECT * FROM mgrs WHERE mgremail='$email'",$link); 

   while ($a_row =mysql_fetch_array ($sql) ) 
       
      &#123; 
       
       
    $subject = "Your Login and Password"; 

      $fromName = $yourname; 

      $fromAddres = $youremail; 

      $message = "Your login name is: $a_row&#1111;mgr]\r\nYour password is: $newpass\r\n"; 



      $temp = mail($email, $subject, $message, "From: ".$fromName." <".$fromAddress.">") or print "Could not send mail.<BR><BR><P>"; 

      if ($temp = true) &#123;print "Check your email for username and new password<P> ";&#125; 


      &#125;
Line:

Code: Select all

$message = "Your login name is: $row&#1111;mgr]\r\nYour password is: $newpass\r\n";
Should be:

Code: Select all

$message = "Your login name is: $a_row&#1111;mgr]\r\nYour password is: $newpass\r\n";
Becaose:

Code: Select all

while ($a_row =mysql_fetch_array ($sql) )
Variable is $a_row and not $row...

Posted: Sun Jul 07, 2002 2:14 am
by cooler75
Hi thanks,
it works. My mistake here, i should be more careful

thank you'