/    Sign up×
Community /Pin to ProfileBookmark

Password reminder script

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]

[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”; }
?>[/code]

Thanks in advance

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ichsieMay 18.2009 — Seems you are on Windows with wamp package? You either install a mail module or upload those scripts to your hosting server with LAMP set correctly.
Copy linkTweet thisAlerts:
@ciara1987authorMay 18.2009 — Seems you are on Windows with wamp package? You either [B]install a mail module[/B] or upload those scripts to your hosting server with LAMP set correctly.[/QUOTE]

Yes I am,do you have any idea where I can download this?

Thanks
×

Success!

Help @ciara1987 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...