Ok, I’m working on a website in Dreamweaver CS4. I made a simple email form with spry validation and a simple PHP code to handle the form and send me an email when the user hits the submit button. Everyhting is working great, except one thing.
I have a template for the site and there are 2 editable areas, as defined by the Dreamweaver template. The script I’m using will direct the user to a new page that has a “Thank you for submitting” message after submitting the form. What I’m trying to do is have the message show up on the same page. I want editable area that the form is in to just change to the “Thank you” message, instead of redirecting to a separate page.
Here is the script I’m using (learned from a tutorial at Tutvid)
[php]<?php
/* Subject and Email variables */
$emailSubject = 'Contact Form Response';
$webMaster = '[email protected]'; /* <---My email address goes here */
/* Gather Data variables */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];
$body = <<<EOD
Name: $nameField
Email: $emailField
Message: $questionField
EOD;
$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results rendered as HTML */
$theResults = <<<EOD
Thank you for submitting.
We will get back to you as soon as possible.
EOD; echo "$theResults";?>[/php]
You can see that at the end of the script it displays a message in html format, but it’s opening a new html page. What I want is for the form to disappear and the message to take it’s place, without going to a new page. I was thinking an echo may be the way to do it, but I’m an extreme newbie ??? when it comes to PHP.
I would appreciate any help you might have for me.
Thanks!