PHP Page is not Sending Email - php

I have a page that has a form for the user to input their email into. Once the form is submitted the email gets checked in my MSSQL table and if it exists in one of the table's rows it will send an email to the user's email. Right now, I correctly put in an existing email and the email is never received. I am trying to make this so that if the user forgets their password, it will retrieve the password from the correct row and send that password to the user's email.
Here is my PHP page code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$conn=mssql_connect('gdm','dr','Rd1!');
mssql_select_db('Gdr',$conn);
if (isset($_POST['forgotpass'])) {
$conn=mssql_connect('gdom','GBdr','d1!');
mssql_select_db('Gdr',$conn);
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$email = $_POST['email'];
$querye = "SELECT password FROM staffportal WHERE email = '".$_POST['email']."'";
$check = mssql_query($querye, $conn);
$check2 = mssql_num_rows($check);
echo "".$check2."";
//if the email doesn't exist it gives an error
if ($check2 != 0) {
print"<p>Thank you, dsa we will get back to you.</p>";
print"<p>Today's date isdsa.</p>";
ob_start();
$tae = "".$_POST['email']."";
echo "".$tae."";
$out2 = ob_get_contents();
ob_end_clean();
var_dump($out2);
var_dump($out2);
$to = "".$out2."";
echo "Emailing to: ".$to."";
$subject = "Financing fordsac ";
$body = "dsdasd \n\n";
$headers = "From: info#gbmtd.ca";
mail($to, $subject, $body, $headers);
} else {
echo "Sorry, the email ".$email." is incorrect.";
} } else {
?>
<form method="POST" action="<?php $_PHP_SELF ?>">
Email:<br />
<input type="text" name="email" id="email"/>
<br /><br />
<input type="submit" id="forgotpass" value="Change Password" name="forgotpass"/>
</form>
<?php } ?>
</body>
</html>
This gets displayed on my page after I hit submit:
1
Thank you, dsa we will get back to you.
Today's date isdsa.
string(22) "kelseynealon#gmail.com" string(22) "kelseynealon#gmail.com" Emailing to: kelseynealon#gmail.com
All help is greatly appreciated. Thank you for any help.

I've had mixed luck with the PHP mail function. You can take a gander at the PHP mail function page http://www.php.net/manual/en/function.mail.php to look for clues. Personally I use PHP SwiftMailer (http://swiftmailer.org/) for any email sending from PHP applications and it works really well.
Here's a generic function I have for using it:
/*
Starting code for sending email via this function:
list($email_logger, $email_mailer) = email_interface();
$message = Swift_Message::newInstance()
->setFrom(array('from#domain.ext' => 'John Doe'))
->setTo(array('to#domain.ext' => 'Jane Doe'))
->setSubject('<SUBJECT>')
->setBody('<BODY>');
$email_mailer->send($message);
*/
// Returns PHP SwiftMailer mailer and logger email interfaces
function email_interface()
{
// Mail configuration
$global_email_config = array(
//'relay_encryption' => 'ssl',
//'relay_host' => 'relayhost.domain.ext',
//'relay_port' => '465',
// 'relay_user' => '<ADDR>',
// 'relay_pass' => '<PASS>',
'smtp_sender' => array(
'sender#domain.ext' => 'Sender Name'
)
);
if (isset($global_email_config['relay_host'])) {
$transport = Swift_SmtpTransport::newInstance();
$transport->setHost($global_email_config['relay_host']);
if (isset($global_email_config['relay_port'])) {
$transport->setPort($global_email_config['relay_port']);
}
if (isset($global_email_config['relay_encryption'])) {
$transport->setEncryption($global_email_config['relay_encryption']);
}
if (isset($global_email_config['relay_user'])) {
$transport->setUsername($global_email_config['relay_user']);
$transport->setPassword($global_email_config['relay_pass']);
}
} else {
$transport = Swift_SendmailTransport::newInstance();
}
$mailer = Swift_Mailer::newInstance($transport);
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
return array(
$logger,
$mailer
);
}

Related

after clicking submit on a contact form, how do i stay on the same page in wordpress?

So I created a custom contact form in WordPress, using PHP. The form sends, and I am receiving emails. The problem I'm having is that once you hit submit, it goes to a post page, and doesn't stay on the original page.
I've tried using a session and header location (didn't work)
I also tried putting this in my action"<?php echo $_SERVER['PHP_SELF']; ?>", doesn't work either. (mail just doesn't send it and sends me to 404 page.
So I'm a little stuck, as to fix this problem. Normally I would have no problems if this was a static web page, but because I'm using WordPress, this task seems to be more troublesome.
Here is a link to the website http://www.indianpointresort.ca/
Here is the php validation:
<?php
/*session_start();
if(!isset($_SESSION['afaisfjisjfijfjiwaefjawsefijef'])){
$url = 'http://www.indianpointresort.ca/';
header("Location:home.php?url=$url");
}*/
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$phone = trim($_POST['phone']);
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
echo "$name | $email | $phone | $subject | $message";
if(isset($_POST['submit'])){
$boolValidationOK = 1;
$strValidationMessage = "";
//validate first name
//validate last name
if(strlen($name)<3){
$boolValidationOK = 0;
$strValidationMessage .= "Please fill in a proper first and last name </br>";
}
//email validation:
$emailValidate = validate_email( $email );// calls the function below to validate the email addy
if(!$emailValidate ){
$boolValidationOK = 0;
$strValidationMessage .= "Please fill in proper email address </br>";
}
//validate phone
$phone = checkPhoneNumber($phone);
if(!$phone){
$boolValidationOK = 0;
$strValidationMessage .= "Please fill proper phone number </br>";
}
//validate subject
if(strlen($subject)<3){
$boolValidationOK = 0;
$strValidationMessage .= "Please fill in a proper subject description </br>";
}
//validate description
if(strlen($message)<3){
$boolValidationOK = 0;
$strValidationMessage .= "Please fill in a proper message </br>";
}
if($boolValidationOK == 1){
//$strValidationMessage = "SUCCESS";
//MAIL SECURITY !!!!!!!
// WE MUST VALIDATE AGAINST EMAIL INJECTIONS; THE SPAMMERS BEST WEAPON
$badStrings = array("Content-Type:",
"MIME-Version:",
"Content-Transfer-Encoding:",
"bcc:",
"cc:");
foreach($_POST as $k => $v){// change to $_POST if your form was method="post"
foreach($badStrings as $v2){
if(strpos($v, $v2) !== false){
// In case of spam, all actions taken here
//header("HTTP/1.0 403 Forbidden");
echo "<script>document.location =\"http://www.bermuda-triangle.org/\" </script>";
exit; // stop all further PHP scripting, so mail will not be sent.
}
}
}
$ip = $_SERVER['REMOTE_ADDR'];
//echo $ip;
/* Spammer List: IP's that have spammed you before ***********/
$spams = array (
"static.16.86.46.78.clients.your-server.de",
"87.101.244.8",
"144.229.34.5",
"89.248.168.70",
"reserve.cableplus.com.cn",
"94.102.60.182",
"194.8.75.145",
"194.8.75.50",
"194.8.75.62",
"194.170.32.252"
//"S0106004005289027.ed.shawcable.net" Phil's IP as test
); // array of evil spammers
foreach ($spams as $site) {// Redirect known spammers
$pattern = "/$site/i";
if (preg_match ($pattern, $ip)) {
// whatever you want to do for the spammer
echo "logging spam activity..";
exit();
}
}
$to = "";
//$subject = " Indian Point";
// compose headers
$headers = "From: Indian Point Resort.\r\n";
$headers .= "Reply-To: $email\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
$message = wordwrap($message, 70);
// send email
mail($to, $subject, $message, $headers);
}
}//end of submit
//validate phone number
function checkPhoneNumber($number){
$number = str_replace("-", "", $number);
$number = str_replace(".", "", $number);
$number = str_replace(" ", "", $number);
$number = str_replace(",", "", $number);
$number = str_replace("(", "", $number);
$number = str_replace(")", "", $number);
if((strlen($number) != 10) || (!is_numeric($number))){
return false;
}else{
return $number;
}
}
//email validation
function validate_email( $senderemail ){ // this is a function; it receives info and returns a value.
$email = trim( $senderemail ); # removes whitespace
if(!empty($email) ):
// validate email address syntax
if( preg_match('/^[a-z0-9\_\.]+#[a-z0-9\-]+\.[a-z]+\.?[a-z]{1,4}$/i', $email, $match) ):
return strtolower($match[0]); # valid!
endif;
endif;
return false; # NOT valid!
}
?>
Here is the form:
<div id="msgForm" class=" msgForm five columns">
<h4>Questions?</h4>
<h5>Send us a message!</h5>
<form id="contactForm" name="contactForm" method="post" action="<?php the_permalink(); ?>">
<p><input type="text" name="name" value="<?php echo $name; ?>" placeholder="name*"/></p>
<p><input type="email" name="email" placeholder="E-mail*"/></p>
<p><input type="text" name="phone" placeholder="Phone #*"/></p>
<p><input type="text" name="subject" placeholder="subject*"/></p>
<p><textarea name="message" placeholder="Message*"></textarea></p>
<p><input type="submit" name="submit" placeholder="Submit"/></p>
<div class="error">
<?php
if($strValidationMessage){
echo $strValidationMessage;
}
?>
</div>
</form>
</div><!--end of form-->
Well, to start off I would remove that gmail account from your info (just to be safe).
Secondly I would advise you to use the sendmail scripts provided by Wordpress.
There are plugins like gravityforms which allow you to make a form and decide all these options without making a static form, nor a new template file for that matter.
You can only change to which page the form will redirect after the refresh (the action will decide that)
If you want it to stay on the same page you can put the page itself in the action and on top put an if statement like
if(isset($_POST['submit'])){
//validation, sendmail, and possibly errors here
}
else{
//show the form
}
anyway, a refreshing webform is as standard as it gets. It's just how it submits things. The only way you could prevent a page is by using jquery or javascript like so: (give your submit an id)
$('#submit').on("click", function(e){
//this prevents any submit functionality (like refresh)
e.preventDefault();
//custom code to get values here and put them in the sendmail function like so:
var message = $('$message').text();
}
Try ajax form submission. And add the insert query in a separate file.

PHP mail() won't send when included in other PHP file with user input email

I am generating a page of information from a database. I need to send an email with the page content as a reminder. (example here takes input as message)
It takes in an email address and is supposed to send the details to that address.
<div class="container">
<?php
$name = $_GET['info'];
if(isset($name)){
$info = explode('|', $name);
/*****************************************************
open conection to the mySQL database
******************************************************/
....
/*****************************************************
Populate the page
******************************************************/
$sql="Select information from table";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result))
{
/*Title*/
echo '<h1>'.$row['post_title'].'</h1><hr>';
/*content*/
echo '<h2>Details: </h2><br>'.$row['post_content'].'<br>';
$content = $row['post_title'];
/*Reminder*/
echo '<div data-role="collapsible">
<h1>Send a reminder</h1>';
include("includes/email_reminder.php");
echo'</div>';
}
/*****************************************************
Close connection
******************************************************/
mysqli_close($con);
} else {
echo'Nothing selected. Go back <br>
<img src="img/icon/Back.png" style="height: 3em" > ';
}
?>
</div>
That creates a form at the bottom of the page to take in the email that needs that needs a reminder.
This is email_reminder.php:
<?php
function spamcheck($field)
{
// Sanitize e-mail address
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
// Validate e-mail address
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
?>
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"]))
{
?>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
Your Email: <input type="text" name="to"><br>
Subject: <input type="text" name="subject"><br>
Message: <textarea rows="10" cols="40" name="message"></textarea><br>
<input type="submit" name="submit" value="Submit Feedback">
</form>
<?php
}
else // the user has submitted the form
{
// Check if the "from" input field is filled out
if (isset($_POST["to"]))
{
// Check if "from" email address is valid
$receivecheck = spamcheck($_POST["to"]);
if ($receivecheck==FALSE)
{
echo "Invalid input";
}
else
{
$to = $_POST["to"]; //receiver
$subject = $_POST["subject"];
$message = $_POST["message"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 70);
// send mail
mail("$to",$subject,$message,"From: myaddress#mail.com\n");
echo "reminder has been sent";
}
}
}
?>
I have used that form in isolation (just opened email_reminder.php on its own) and it sent emails correctly from whichever email address I used. It just doesn't send when included in the other script.
include(emai_reminder.php); needs single quotes surrounding the file name (and email correctly spelled: include('email_reminder.php');
But, it looks like you need more help than just this. For example, there is no field FROM in your form, although you reference $_POST["from"]. You're running validation against that variable, which doesn't exist, which fails validation, which prevents the else if block from running, which prevents mail() from ever being called.
Several reasons why mailing to different user-defined addresses may not work:
1.) Check the result from the mail() call is TRUE, just to make sure the underlying sendmail (if you are on Linux) did not return an error.
2.) Add additional headers to prevent problems when delivering mails to foreign SMTP hosts, an example may be found on PHP doc for mail()
3.) In some cases (i.e. when using SMTP on Windows) using the PEAR Mail package may solve your problem. It also supports ASMTP and error trapping is much easier compared to the mail() function.

PHP form mail to work with invisible form field to filter bots

I read this post: What is a good invisible captcha? about using a hidden field in a web form to stop basic bots from pelting your website with spam mail via your web sites form mail. I'm currently using a php script to process my form mail. I built the script by following a 'bullet proff web form' tutorial I found. It looks like this:
<?php
// Pick up the form data and assign it to variables
$name = $_POST['name'];
$email = $_POST['email'];
$topic = $_POST['topic'];
$comments = $_POST['comments'];
// Build the email (replace the address in the $to section with your own)
$to = 'hello#cipherbunny.com';
$subject = "New message: $topic";
$message = "$name said: $comments";
$headers = "From: $email";
// Data cleaning function
function clean_data($string) {
if (get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
$string = strip_tags($string);
return mysql_real_escape_string($string);
}
// Mail header removal
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
);
$string = preg_replace($headers, '', $string);
return strip_tags($string);
}
// Pick up the cleaned form data
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$topic = remove_headers($_POST['topic']);
$comments = remove_headers($_POST['comments']);
// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);
// Redirect
header("Location: http://foobar/success.html");
I'd like to modify this script so that if a hidden field with the identifier 'other_email' was filled in then the form email wouldn't get sent. I'm guess it's as straight forward as wrapping the above code in an if statement to check if the field is complete. I've tried adding this under the "//Pick up the form data and assign it to variables" code:
$testBot = $_POST['other_email'];
then writing:
if(other_email == "") //If other_email form section is blank then...
{
run all the code above inserted here;
}
else
{
Don't know what I should put here to stop it posting, yet still show the success form so
the spam bot don't know
}
any help much appreciated. I have to say I don't really have a lot of php knowledge, I'm just starting to learn about it and thought form mail would be a good start.
How do I make this work in PhP?
if(other_email == "") //If other_email form section is blank then...
{
run all the code above inserted here;
}
else
{
header("Location: http://foobar/success.html");
}
keeping it very simple, it will work for you..
actually, it will
not submit / mail you anything...so NO SPAM
a simple bot will take it as it did it...
if you can use php on success page, then set a session variable (to make bot think it did its job, something like email_sent=true or success=true) and use that variable in success page, you will do it in else case where bot submitted the form..
Do you mean send message with fields?
Try this:
<?php
// Pick up the form data and assign it to variables
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$topic = $_REQUEST['topic'];
$comments = $_REQUEST['comments'];
// Build the email (replace the address in the $to section with your own)
if($name !== null && $email !== null && $topic !== null && $comments !== null){
$to = 'hello#cipherbunny.com';
$subject = "New message: $topic";
$message = "$name said: $comments";
$headers = "From: $email";
// Data cleaning function
function clean_data($string) {
if (get_magic_quotes_gpc()) {
$string = stripslashes($string);
}
$string = strip_tags($string);
return mysql_real_escape_string($string);
}
// Mail header removal
function remove_headers($string) {
$headers = array(
"/to\:/i",
"/from\:/i",
"/bcc\:/i",
"/cc\:/i",
"/Content\-Transfer\-Encoding\:/i",
"/Content\-Type\:/i",
"/Mime\-Version\:/i"
);
$string = preg_replace($headers, '', $string);
return strip_tags($string);
}
// Pick up the cleaned form data
$name = remove_headers($_POST['name']);
$email = remove_headers($_POST['email']);
$topic = remove_headers($_POST['topic']);
$comments = remove_headers($_POST['comments']);
// Send the mail using PHPs mail() function
mail($to, $subject, $message, $headers);
// Redirect
header("Location: http://foobar/success.html");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<title>Send</title>
</head>
<body>
<form action="#" method="POST">
Name : <input type="text" name="name" /><br />
Email : <input type="text" name="email" /><br />
Topic : <input type="text" name="topic" /><br />
Comments : <textarea name="comments"></textarea><br />
<input type="submit" value="Send" />
</form>
</body>
</html>

two foreach loops combined for email sending

I am trying to take a two text areas with multiple emails, one with the "from" emails, and one with the "to" emails. Combine the emails line by line and send emails out accordingly.
Ex:
"To" list:
mike#gmail.com
nick#hotmail.com
adam#yahoo.com
"From" list:
ashley#gmail.com
brittney#yahoo.com
racheal#hotmail.com
I want a email sent to:
mike#gmail.com from ashley#gmail.com
nick#hotmail.com from brittney#yahoo.com
adam#yahoo.com from racheal#hotmail.com
Any help would be greatly appreciated. Thanks in advanced.
Below is the script I got so far, It sends to multiple emails from one email.
<?php
if (isset($_POST['submit']))
{
// Execute this code if the submit button is pressed.
$raw_email_account = $_POST['email_from'];
$email = $_POST['email_to'];
$sent = "";
$invalid = "";
//Separating each line to be read by foreach
$list = explode("\n",$email);
//Rendering the separeted data from each line
foreach($list AS $data) {
//Separating each line to be read by foreach
$item = explode(":",$data);
$mail_body = '<html><body>email here</body></html>';
$subject = "subject here";
$headers = "From:".$raw_email_account."\r\n";
$headers .= "Content-type: text/html\r\n";
$to = $item[0];
$mail_result = mail($to, $subject, $mail_body, $headers);
if ($mail_result) {
$valid++;
} else {
// write into an error log if the mail function fails
$invalid++;
}
}
}
?>
<html>
<head>
</head>
<body>
<form action="email_sender.php" method="POST">
<div align="center">From Email Accounts: <textarea name="email_from" cols="100" rows="60"></textarea></div><br />
<div align="center">To Email Accounts: <textarea name="email_to" cols="100" rows="60"> </textarea></div><br />
<div align="center"><input type="submit" name="submit"></div>
<br>
Valids: <?php echo $valid;?>
<br>
Invalids: <?php echo $invalid;?>
</body>
</html>
If the array is by default, the indexes will coincide. So you can do something like this.
$toList = array(..);
$fromList = array(...);
foreach($toList as $key => $value) {
$toAddress = $value;
$fromAddress = $fromList[$key];
//..
//.. Go on with you mail function
}
Add logic that provides same count of $email and $raw_email_account arrays before foreach loop.
$list = explode("\n",$email);
$list2 = explode("\n", $raw_email_account);
foreach($list AS $key=>$data) {
...
$headers = "From:".$list2[$key]."\r\n";
...
}
You can use array_combine() to solve that problem easily.
In that case, you first combine the two arrays, and then loop through the resulting array to perform the sending e-mail action.

php forgot password page

I got this code from a website and I have been altering it to fit my needs. The problem that I am facing is that the password reset page is not firing a new password off by php mail but instead it is refreshing the page and the user is stuck on a php include file and not the site.
I know some php but this seems to be beyond me. After 12+hrs of trying different things I am asking for help :)
I hope its an easy fix. Thanks in advance for your help and code snippets.
<?php
include 'dbc.php';
/******************* ACTIVATION BY FORM**************************/
if ($_POST['doReset']=='Reset')
{
$err = array();
$msg = array();
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
if(!isEmail($data['user_email'])) {
$err[] = "ERROR - Please enter a valid email";
header("Location: index.html?p=unknownuser");
}
$user_email = $data['user_email'];
//check if activ code and user is valid as precaution
$rs_check = mysql_query("select id from users where user_email='$user_email'") or die (mysql_error());
$num = mysql_num_rows($rs_check);
// Match row found with more than 1 results - the user is authenticated.
if ( $num <= 0 ) {
$err[] = "Error - Sorry no such account exists or registered.";
header("Location: index.html?p=unknownuser");
//exit();
}
if(empty($err)) {
$new_pwd = GenPwd();
$pwd_reset = PwdHash($new_pwd);
//$sha1_new = sha1($new);
//set update sha1 of new password + salt
$rs_activ = mysql_query("update users set pwd='$pwd_reset' WHERE
user_email='$user_email'") or die(mysql_error());
$host = $_SERVER['HTTP_HOST'];
$host_upper = strtoupper($host);
//send email
$message =
"Here are your new password details ...\n
User Email: $user_email \n
Passwd: $new_pwd \n
Thank You
Administrator
$host_upper
______________________________________________________
THIS IS AN AUTOMATED RESPONSE.
***DO NOT RESPOND TO THIS EMAIL****
";
mail($user_email, "Reset Password", $message,
"From: \"Client Password Reset\" <clientservices#example.com>\r\n" .
"X-Mailer: PHP/" . phpversion());
header("Location: index.html?p=newpassword");
exit();
}
}
/*
mail($user_email, "Reset Password", $message,
"From: \"Client Registration\" <clientservices#example.com>\r\n" .
"X-Mailer: PHP/" . phpversion());
$msg[] = "Your account password has been reset and a new password has been sent to your email address.";
//header("Location: index.html?p=newpassword");
//$msg = urlencode();
//header("Location: forgot.php?msg=$msg");
//exit();
}
}
*/
?>
<script language="JavaScript" type="text/javascript" src="jquery/jquery-1.6.4.min.js"></script>
<script language="JavaScript" type="text/javascript" src="jquery/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#actForm").validate();
});
</script>
<?php
/******************** ERROR MESSAGES*************************************************
This code is to show error messages
**************************************************************************/
if(!empty($err)) {
echo "<div class=\"msg\">";
foreach ($err as $e) {
echo "* $e <br>";
}
echo "</div>";
}
if(!empty($msg)) {
echo "<div class=\"msg\">" . $msg[0] . "</div>";
}
/******************************* END ********************************/
?><div id="clientLogin">You are about to request a reset of your client account password | Login<br>
<form action="forgot.php" method="post" name="actForm" id="actForm" style="margin-top:5px;">
Your Email <input name="user_email" type="text" class="required email" id="txtboxn" size="25"><input name="doReset" type="submit" id="doLogin3" value="Submit" class="button"></form></div>
You have:
mail($usr_email, "Reset Password", $message...);
When it looks like you should have
mail($user_email, "Reset Password", $message...);
Notice you used $usr_email instead of $user_email.
That is why no email is being sent. Then it looks like the user is redirected to index.html?p=newpassword so depending on what that page is it may appear to just be reloading the same page.
UPDATE:
Also, you have the element doReset with a value of Submit and in your PHP code you are checking to see that $_POST['doReset'] == Reset instead of Submit.
<input name="doReset" type="submit" id="doLogin3" value="Submit" class="button">
Change
if ($_POST['doReset']=='Reset')
to
if ($_POST['doReset']=='Submit')

Categories