Jump to content

forgot password help


slj90

Recommended Posts

I have a form where the user puts their email in, if its found, then they are sent their password.

 

The action script I am using to do this is below..

 

<?php
  //Include the connection details, open $connection and select database
include ("connection.php");
   
// value sent from form
$Email=$_POST['Email'];

// table name
$Customer;

// retrieve password from table where e-mail = $email_to([email protected])
$sql="SELECT Password FROM $Customer WHERE Email='$Email'";
$result=mysql_query($sql);

// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);

// compare if $count =1 row
if($count==1){

$rows=mysql_fetch_array($result);

// keep password in $your_password
$your_password=$rows['Password'];

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email_to;

// Your subject
$subject="Your password here";

// From
$header="from: your name <your email>";

// Your message
$messages= "Your password for login to our website \r\n";
$messages.="Your password is $your_password \r\n";
$messages.="more message... \r\n";

// send email
$sentmail = mail($to,$subject,$messages,$header);

}

// else if $count not equal 1
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Password Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send password to your e-mail address";
}

?>

 

 

 

I currently get the error

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /study_D/undergrad/c3221281/webpages/my_iis_website/forgotpassaction.php on line 17
Not found your email in our databaseCannot send password to your e-mail address

 

Line 17 is...

 

$count=mysql_num_rows($result);

 

 

Any ideas?

 

 

Also, the form code..

 

<form action = 'forgotpassaction.php' method="GET"> 
   <p>Email:<br /> <input type="text" name="Email" value=<?php print $row["Email"] ?> ></p> 
      </p> 
    <p><input type="submit" value="Get Password" name="GetPass" > </p> 
  </form>         

 

 

Thanks alot guys

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/188888-forgot-password-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.