forgot password problem..
Posted: Thu May 19, 2005 2:14 pm
I got a script for people to have there username and password sent to them well for some reason it will send it out just by itself but when i add it to my template script it just says the email failed.. here is the script
forgot.php
can someone find what can be the problem?
Thanx
Smackie
forgot.php
Code: Select all
<?php
if(isset($_POST['submit']))
{
foreach( $_POST as $key => $value )
{
${$key} = htmlspecialchars($value);
}
mysql_connect("localhost","db","*******");
mysql_select_db(table);
// do som config
$sitename ="Webcom-Online";
$sitemail = "Admin@webcom-online.org";
$sql = mysql_query("SELECT * FROM users WHERE user_name='$name' AND email_address='$email'");
// if no single match
if(mysql_num_rows($sql) <> 1)
{
echo "The user name and email do not match.";
exit;
}
$fPass = mysql_fetch_array($sql);
$username = $fPass[user_name];
$password = $fPass[password];
// prepare email
$sendto = $email;
$from = $sitename;
$subject = "Your user info";
$message = "Here is your username and password.\nIf you didnt request it dont worry, your username and password only goes to your email box..\n\nUsername: $username\nPassword: $password\n\n\nYou requested the email from $sitename
";
// setting some headers to try and avvoid it as garbage mail
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "From: $sitename <$sitemail>\r\n";
$headers .= "Reply-to: $sitename <$sitemail>\r\n";
$headers .= "Return-Path: $sitename <$sitemail>\r\n";
$headers .= "X-MSMail-Priority: Low\r\n";
$headers .= "X-Mailer: php\r\n";
// do send
mail($sendto, $subject, $message, $headers, "-f" . $sitemail) or die('Email failed');
print "Your Password has been sent to $sendto";
}
?>
<center>
<form action="<?= $PHP_SELF ?>" method="post">
Name: <input type="text" name="name" size="24" border="0"><br>
E-mail: <input type="text" name="email" size="24" border="0"><br>
<input type="hidden" name="go" value="1" border="0"><input type="submit" name="submit" value="request email" border="0">
</form></center>Thanx
Smackie