Hi guys I`m trying to send a forgotten password to an email address entered which searches the DB for that address and sends the corresponding email,
When I enter an invalid Email address I receive”email not valid”
When I enter a valid email address I recieve the follwoing message
“email with password was send
Warning: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set() in C:wampwwwPHPNewPasswordforgot_password.php on line 35
“
My code
[code=html]<form method=”post” action=”forgot_password.php”>
Email: <br />
<input type=”text” name=”user_email” size=”50″ maxlength=”50″/> (50 Characters Max)
<br />
<br />
<input type=”submit” value=”Sent new password” />
</form>
[code=php]<?php
$user_email = $_POST[‘user_email’];
$dbname = “heskdb”;
$conn = mysql_connect (“localhost”,”root”,”password”) or
die (‘cannot connect to database error: ‘.mysql_error());
mysql_select_db ($dbname);
if($user_email != “”)
{
$result = mysql_query(“select * from users where email = ‘$user_email'”) or die(mysql_error());
$count=mysql_num_rows($result);
if($count != 1){
echo “no user with this email”;
$alert = “<div class=’alert’>We’re sorry, but we could not find a user with that email address.</div>”;
}
else {
echo “email with password was send”;
$alert = “<div class=’alert’>Your username and password have been emailed to you.</div>”;
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$username = $row[‘user_name’];
$password = $row[‘password’];
$msg = “Your login information is:nn”;
$msg .= “Username: $usernamen”;
$msg .= “Password: $passwordn”;
mail($user_email, “Login Information”, $msg, “From:[email protected]”);
}
} else {
echo “user email not set”; }
?>
Thanks in advance