PDA

View Full Version : Password script.



Lilian
05-06-2007, 09:18 PM
I have this script which sends forgotten password to your email. But it sends it from "[email protected]". How can I change it so that it sends from the email I want it to?


<?PHP
ob_start();
include('configuration.php');
/*
Forgot Password script
*/
if ($_POST['Submit'])
{
$Username = htmlspecialchars($_POST['username']);
if (empty($Username))
{
die("No username was given!");
}
$Search_Query = "SELECT `email` FROM `sexy` WHERE `username` = '$Username'";
$Search_User = mysql_query($Search_Query) or die(mysql_error());

if (mysql_num_rows($Search_User) == 0)
{
die("Invalid username");
}
$DB_Results = mysql_fetch_array($Search_User);
$Email = $DB_Results['email'];

$New_Password = str_shuffle('D4gh7g55CdoP');
usleep(600000);
//Replace "$Email" with your email address. Explanation: mail("RECEIVER EMAIL", "MESSAGE", "YOUR EMAIL")
mail([email protected], 'Password Recovery', 'My Message.

Your new password is '.$New_Password. '', '[email protected]');
$New_Password = md5($New_Password);
$Update_Password_Query = "UPDATE `sexy` SET `password` = '$New_Password' WHERE `email` = '$Email'";
$Update_Password = mysql_query($Update_Password_Query) or die(mysql_error());
die("Password Send");
} else {
?>

Verrou
06-06-2007, 06:06 AM
What do i need to do with MySQL?

Recursion
06-06-2007, 06:39 AM
Post configuration.php please.

Drompo
06-06-2007, 04:17 PM
$from = "myemailaddress.this.com";


mail("[email protected]", "Password Recovery", "My Message.

Your new password is '.$New_Password. '", "$from");

Your sending the from bit as an additional header.

Lilian
06-06-2007, 04:30 PM
Hmm I changed it now its not sending the email but I get no error O.o?

Sygon..
06-06-2007, 04:46 PM
mail([email protected], 'Password Recovery', 'My Message.

Your new password is '.$New_Password. '', '[email protected]');



To:




$headers = "From: Me <[email protected]>\n";
$headers .= "Reply-To: me <[email protected]>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

mail('[email protected]', 'Password Recovery', 'My Message.

Your new password is '.$New_Password. '', $headers);



From: http://www.php.net/mail

Drompo
06-06-2007, 04:47 PM
$from = "From: myemailaddress.this.com\r\n";


mail("[email protected]", "Password Recovery", "My Message.

Your new password is '.$New_Password. '", "$from");

Try that

Lilian
06-06-2007, 05:49 PM
Nope =[

Sygon..
06-06-2007, 06:23 PM
Nope =[

What is the matter:

Is it not working?

Or do you want to change something

Lilian
06-06-2007, 06:24 PM
I get no errors but it doesnt send the email with new password.

Sygon..
06-06-2007, 06:28 PM
Try this:




$headers = "From: Me <[email protected]>\n";
$headers .= "Reply-To: me <[email protected]>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

mail($Email, 'Password Recovery', 'My Message.

Your new password is '.$New_Password. '', $headers);



It should work :)

Want to hide these adverts? Register an account for free!