I have an HTML5 form set up like so:
<form id="contact-form" action="php/email.php">
<fieldset>
<ul id="form">
<li>
<label for="name">Name:</label>
<input id="name" name="name" type="text" placeholder="First and Last Name" required />
</li>
<li>
<label for="email">Email:</label>
<input id="email" name="email" type="email" placeholder="Enter email address" />
</li>
<li>
<label for="message">Message:</label>
<textarea id="message" name="message" placeholder="Leave comments here..." required></textarea>
</li>
</ul>
<a id="back" href="index.html"><-- Home</a>
<input type="submit" id="submit" value="Submit Form" class="button"/>
</fieldset>
</form>
and a small PHP script that sends me an email. I am wondering how to redirect the user to a Thank You page. Any suggestions?
Sorry, here is the PHP script:
<?php
$name = $_GET['name'];
$visitorEmail = $_GET['email'];
$message = $_GET['message'];
$email_from = "lesniakbj@jay.washjeff.edu";
$email_subject = "New Form Submission! - From: " + $visitorEmail;
$email_body = "Here is the message from $name: \n $message";
$to = "lesniakbj@jay.washjeff.edu";
$headers = "From: $email_from \r \n";
$headers .= "Reply-To: $visitorEmail \r \n";
mail($to, $email_subject, $email_body, $headers);
echo "Success! You've sent mail!";
?>
EDIT:
Ok, the problem that I have with this:
~/MyMobileApp/php/email.php
and all of my content:
~/MyMobileApp/
I want to redirect back to a local page, my index page that is located one folder above my php script. The problem with the header is that it can’t go above the directory that it is currently in; maybe I should add a thank you html page in that folder and redirect? Or is there a better way?
After your php sends the email, add this php snippet: