I am really stuck on this problem. How can I make it work? It selects from email the user and resends on email the password.
I got an error on line 45 but cannot find it:
Parse error: syntax error, unexpected 'not' (T_STRING) in /home/xxxxxx/public_html/xxxx/email.php on line 45
Here is my code:
<?php
$host="localhost"; // Host name - update all those fields
$username="xxxxx"; // Mysql username
$password="xxxx"; // Mysql password
$db_name="xxxxxx"; // Database name
//Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB");
// value sent from form
$email_to=$_POST['email_to']; // table name
$tbl_name=tz_members;
// retrieve password from table where e-mail is equal
$sql="SELECT usr, pass, regIP 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);
$your_username=$rows['usr']; $your_password=$rows['pass']; $your_ip=$rows['regIP']; $pass = substr(md5($your_ip.microtime().rand(1,100000)),0,6); // create a new pass
mysql_query(" UPDATE tz_members SET pass='".md5($pass)."' WHERE email='".$email_to."'"); // update the db
// ---------------- SEND MAIL FORM ---------------- // send e-mail to ...
$to=$email_to;
// Your subject
$subject="Your password here";
// From
$header="from: your name ";
// Your message
$messages= "Your password for login has been reset.\r\n"; $messages.="The new password is $pass \r\n"; $messages.="Regards \r\n";
// send email
$sentmail = mail($to,$subject,$messages,$header);
mysql_free_result($result); }
// else if
$count not equal 1 else if ($count==0) echo "Your email was not found in our database"; else echo "More than one (".$count.") email records was found in our database, please contact the administrator.";
// if your email succesfully sent
if($sentmail) { echo "The new password has been reset and sent to the email on record."; } else { echo "Cannot send the password to this e-mail address"; }
?>
It's a form that reset password from database.