Ok ... so I grabbed this PHP contact form from a combination of several different sites and from the predecessor. I fought with him for hours and cannot understand.
In fairness, know that PHP is not my strong suit, in general (I am a client-side programmer). Here is the code below, please help if you can. Thanks!
Here are some of the error messages I saw:
Most recent: * Parse error: syntax error, unexpected T_IF in / home / [...] on line 11 *
Before that there was an error message, but I believe that I fixed the "empty field" part:
It looks like you left an empty field.
Please make sure that you fill in your full name, email address, subject and details. Click the back arrow to return to the contact form.
From: ... List :; syntax illegal for recipient addresses
Reply-To: ... List :; syntax illegal for recipient addresses
X-Mailer: ... List :; syntax illegal for recipient addresses
Thank you [name] for contacting us!
Here is the HTML
<form action="contactus.php" method="post" class="create"> <fieldset> <legend align="center">Please fill out details below and click "Submit"</legend> <div> <label for="fullname" class="fixedwidth">Full Name</label> <input type="text" name="fullname" id="fullname" class="input2"/> </div><br/> <div> <label for="email" class="fixedwidth">Email</label> <input type="text" name="email" id="email" class="input2"/> </div><br/> <div> <label for="subject" class="fixedwidth">Subject</label> <input type="text" name="subject" id="subject" class="input2"/> </div><br/> <div> <label for="details" class="fixedwidth">Body</label> <textarea id="details" name="details" cols="62" rows="20"></textarea> </div> <div class="buttonarea"> <input type="submit" name="submit" id="submit" value="Submit"/> </div> </fieldset> </form>
... and here is the contactus.php file:
<?php $fullname = $_POST['fullname']; $subject = $_POST['subject']; $details = $_POST['details']; $email = $_POST['email']; //*** Function to check email address */ function checkemail($email) { $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)@[a-z0-9-]+(\.[a-z0-9-]+)(\.[az]{2,3})$/' if (eregi($regex ,$email)) { return true; } else { return false; } } //*** Check to see if the email address is valid */ else if (checkemail($email) == false) { echo "<br/><br/><p><center>It appears that you have entered an invalid email address.<br/> Please check your email again.</p>"; } //*** Mail Processing */ if ($_POST['submit']) { //Check for blank fields if ($fullname !== "" && $email !== "" && $subject !== "" && $details !== "") { echo "<br/><br/><p><center>It appears that you left a blank field.<br/> Please make sure you fill in your full name, email address, subject, and details.<br/> Click the back arrow to return to the contact form.</p>"; } //*** Send Mail**/ $to = ' sgraffito22@gmail.com '; $fullname = $_POST['fullname']; $subject = $_POST['subject']; $details = $_POST['details']; $headers = 'From: '.$email."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $fullname, $subject, $details, $headers); echo "<br><br><p><center>Thank you, $fullname, for contacting us!</p><br><br>"; } ?>