I am using Dreamweaver CS4 to build a website. On my contact page, I made a form with spry validation. I used a tutvid tutorial to learn a simple form handler script (I'm a complete newb at PHP) and everything works great. The only problem I'm having is, in my Dreamweaver template, I have an editable region that has the form. When the user clicks to submit the form, a new html page opens up that looks nothing like my website.
What I'm trying to accomplish is having the form disappear and be replaced in the same editable region with my "thank you" message. This way, the user just submits, the form disappears, and they get a thank you message on the same page, in the same place where the form was.
Here is the form code:
<form id="frmContact" name="frmContact" method="post" action="contact_form.php">
<fieldset><legend>Submit a question or comment...</legend>
<p>
<label for="name">Name:</label>
<span id="spryName">
<input type="text" name="name" id="name" />
<span class="textfieldRequiredMsg">Name is required.</span><span class="textfieldMinCharsMsg">Must have at least 3 characters.</span><span class="textfieldMaxCharsMsg">Must not exceed 20 characters.</span></span></p>
<p>
<label for="email">Email:</label>
<span id="spryPassword">
<input type="text" name="email" id="email" tabindex="10" />
<span class="textfieldRequiredMsg">Email address is required.</span><span class="textfieldInvalidFormatMsg">Not a valid email address.</span><span class="textfieldMinCharsMsg">Not a valid email address.</span><span class="textfieldMaxCharsMsg">Not a valid email address.</span></span></p>
<p>
<label id="message" for="question">Please tell us how we can help you:</label><br />
<span id="spryText">
<textarea name="question" id="question" cols="45" rows="5" tabindex="20"></textarea><br />
<span class="textareaRequiredMsg">A question or comment is required.</span><span class="textareaMinCharsMsg">Must have 16 characters minimum</span><span class="textareaMaxCharsMsg">Must not exceed 500 characters.</span></span></p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" tabindex="30" />
</p>
</fieldset>
</form>
Here is the PHP script:
<?php
/* Subject and Email variables */
$emailSubject = 'Contact Form Response';
$webMaster = 'centerline.computers@gmail.com';
/* Gather Data variables */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];
$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Message: $questionField <br>
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
<html><body>
<h2>Thank you for submitting.</h2>
<p>We will get back to you as soon as possible.</p>
</body>
</html>
EOD;
echo "$theResults";
?>
Thanks for any help you might have for me!