0

I'm trying to get a simple web form to work but I have almost no knowledge of psp, so bear with me. This is the php file

<?php
if(!isset($_POST['submit'])) {
    $emailbody = 'name: '.$_POST['name']."\n"
    .'email: '.$_POST['email']."\n"
    .'message: '.$_POST['message']."\n";    
    mail('myemail@email.com', 'Subject line', $emailbody);
    header('location: thankyou.html');
} else {
    header('location: contact.html');
}
?>

And this is the form html:

<form method="post" action="test.php">
<!-- ===START FIELDS=== -->
<div class="fieldset">
<h2 class="contact-form">Contact Us</h2>
<div class="fields">
<p class="row">
<label>Name:</label>
<input type="text" id="first-name" name="name" class="field-large" required="required" aria-required="true" /></p>   
<p class="row"><label>Email<span class="required">*</span>:</label><input type="email" id="email" name="email" placeholder="yourname@example.com" class="field-large" /></p>   
<p class="row"><label>Message:</label><textarea id="message" id="message" name="message" cols="40" rows="5" class="field-large"/></textarea></p>
<input type="submit" value="submit" name="send" class="btn" />
</div>
</div>
</form>

On clicking 'submit'I get redirected to the 'thank you' page, but no email is received on my end. I'm testing this on XAMPP in case it matters. I've checked similar questions where it was suggeted to add ! before isset but this didn't help.

  • You do realise you're saying `IF (POST[submit] IS NOT SET) {`, so that won't work. – Darren Jun 09 '15 at 01:03
  • Do you mean because of the ! before isset? If I remove that and press submit, the redirection to thankyou.html does not work. – skepticalmind Jun 09 '15 at 01:25
  • Thats right. And it doesn't send because your submit button is called `send`, not `submit`. So change it to this: `if(isset($_POST['send'])) {` – Darren Jun 09 '15 at 01:26
  • You're right, it's called send, thanks for that. But the emails are still not getting through. – skepticalmind Jun 09 '15 at 01:32

0 Answers0