- This topic is empty.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
May 5, 2010 at 4:19 pm #28940noahgelmanParticipant
I have a form set up and it works. A user can type in their email and they’ll receive emails of updates and news. The problem is the page redirects after clicking the submit button. It redirects to a blank page (contact.php) which displays text depending on whether the email went through (i.e "Thank you. I will get back to you very soon." or "Sorry: An error occurred, please try again later.").
What I want to do is have the form quickly fade out and just use AJAX to load the page text into the div the form was in. Here is my form and script.
Code:Code://///////////////////////// //Begin Configuration /////////////////////////// // Your email $to = "noahgelman@yahoo.com" . ", " ; // Email Subject $subject = "Email for News and Updates" . "mkeefeDESIGN"; // Server name, to display in the headers $server_name = "mkeefeDESIGN"; /////////////////////////// //End Configuration /////////////////////////// if (!empty($_POST['send']) || !empty($_GET['send'])) { $action = (!empty($_POST['send'])) ? $_POST['send'] : $_GET['send']; } else { $action = ''; } $build_message = false; if($action != "") { $build_message = true; $message = trim($_POST['message']); $name = trim($_POST['name']); $email = trim($_POST['email']); $time = time(); $date = date("F j, Y", time()); $headers = "MIME-Version: 1.0rn"; $headers .= "Content-type: text/plain; charset=UTF-8rn"; $headers .= "From: $emailrn"; $headers .= "X-mailer: " . $server_name . " Serverrn"; } if($build_message) { /* message */ $message = " Sender Name: $namen Sender E-Mail: $emailn Date Sent: $daten Message:n----------------------------------------n$message n"; if(mail($to, $subject, $message, $headers)) { $result = "Thank you.
I will get back to you very soon.
“;
}
else
{
$result = “Sorry: An error occured, please try again later.”;
}
}// Output a result Message
print $result;
?> -
AuthorPosts
Viewing 1 post (of 1 total)
- The forum ‘Back End’ is closed to new topics and replies.