I have an HTML mail form that posts to a PHP file, then returns a new html “confirmation page”. I want the feedback to post in the original html page just below the send button, not call a separate file. like in a span or div tag. Here is my PHP code:
[php]
<?php if(isset($_POST['submit'])) { $to = "[email protected]"; $subject = "From your Site!"; // data the visitor provided $name_field = filter_var($_POST['name'], FILTER_SANITIZE_STRING); $email_field = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); $comment = filter_var($_POST['comment'], FILTER_SANITIZE_STRING); //constructing the message $body = " From: $name_field\n\n E-Mail: $email_field\n\n Message:\n\n $comment"; // ...and away we go! mail($to, $subject, $body); // redirect to confirmation header('Location: confirmation.htm'); } else { // handle the error somehow } ?>[/php]
And the HTML:
<form action="mailer.php" method="POST">
<div class="span-12 form-row">
<span>Name:</span><input name="name" type="text">
</div>
<div class="span-12 form-row clear">
<span>Email:</span><input name="email" type="text">
</div>
<div class="span-12 form-row clear">
<span>Message</span><textarea name="comment"></textarea>
</div>
<div class="span-6 prepend-2">
<input name="submit" type="submit" value="Send"><span class="form-status">Please complete all fields<span>
</div>
</form>
It is the (span class=“form-status”) where I would like the feedback to post.
Yes, I am new to PHP. Any help is greatly appreciated!
Thanks!