Question
Forgotten password help
I am building my site using Dreamweaver & PHP. I found a
forgotten password script on PHPeasystep but have found adjusting
the script to work on my site rather difficult. Here is the script
<?php require_once('Connections/member.php');
// value sent from form
$email_to=$_POST['email_to'];
// table name
$tbl_name=member;
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$sql="SELECT password FROM $tbl_name WHERE email='$email_to'";
$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";
}
?>
Once I submit a password, I get the following message
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apachefriends\xampp\htdocs\runthrowcatch\send_password_ac.php on line 15
Not found your email in our databaseCannot send password to your e-mail address
My Primary key in my database table is loginname and there is no Autoincrement ID number. I am not sure what I need to adjust in this script to make it work. Any assistance would be greatly appreciated.
<?php require_once('Connections/member.php');
// value sent from form
$email_to=$_POST['email_to'];
// table name
$tbl_name=member;
// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
$sql="SELECT password FROM $tbl_name WHERE email='$email_to'";
$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";
}
?>
Once I submit a password, I get the following message
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apachefriends\xampp\htdocs\runthrowcatch\send_password_ac.php on line 15
Not found your email in our databaseCannot send password to your e-mail address
My Primary key in my database table is loginname and there is no Autoincrement ID number. I am not sure what I need to adjust in this script to make it work. Any assistance would be greatly appreciated.