I am trying to make a simple form that only has a message box and a submit button.
I took a contact form I am using on another page and just removed all fields I didn't need. The form "appears" to submit but I never receive it in my email. I am sure I have made a simple mistake in the code.
Heres what I am using:
index.php (header):
index.php (body):Code:<?php error_reporting(E_ALL ^ E_NOTICE); // hide all basic notices from PHP //If the form is submitted if(isset($_POST['submit'])) { // we need at least some content if(trim($_POST['comments']) === '') { $commentError = 'You forgot to enter a message!'; $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['comments'])); } else { $comments = trim($_POST['comments']); } } // upon no failure errors let's email now! if(!isset($hasError)) { $emailTo = 'me@gmail.com'; $subject = 'Submitted message on Site.ca from '.$name; $sendCopy = trim($_POST['sendCopy']); $body = "Comments: $comments"; $headers = 'From: ' .' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); // set our boolean completion value to TRUE $emailSent = true; } } ?>
Can anyone spot what I am doing wrong? I need the form to reload the page on submit, which it currently does.Code:<div id="actform"> <h3><img src="./_layout/images/bg-checklist.png" />Got an idea? Let us know below</h3> <form action="index.php" method="post"> <textarea name="comments" class="actform" placeholder="Message:"></textarea> <input type="submit" value="Submit" name="submit" class="subname" /> </form> <div class="spacer"></div> </div>
thanks.



Reply With Quote

Bookmarks