Form Mailer isue
-
I’m currently working on this contact form and something seems to be wrong with the form mailer. When the suer fills and submits the form, it shows a blank page when it should thank the person by his/her name. The form is as shown bellow.
<form action="/we-thank-you/" method="post" enctype="plain/text" id="contacter"> <div id="contactleft"> <div class="textboxer"><span id="sprytextfield1"> <label for="name"></label> <input name="name" type="text" class="texter" id="name" /> <span class="textfieldRequiredMsg">A value is required.</span></span></div><!-- End Textboxer --> <div class="textboxer"><span id="sprytextfield2"> <label for="email"></label> <input name="email" type="text" class="texter" id="email" /> <span class="textfieldRequiredMsg">A value is required.</span></span></div><!-- End Textboxer --> <div class="textboxer"><span id="sprytextfield3"> <label for="phone"></label> <input name="phone" type="text" class="texter" id="phone" /> <span class="textfieldRequiredMsg">A value is required.</span></span></div><!-- End Textboxer --> <div class="textboxer"><span id="sprytextfield4"> <label for="subjec"></label> <input name="subjec" type="text" class="texter" id="subjec" /> <span class="textfieldRequiredMsg">A value is required.</span></span></div><!-- End Textboxer --> <div class="textboxer"> <div class="kode"> <span id="txtCaptchaDiv" style="color:#F00"></span><br /> <!-- this is where the script will place the generated code --> <input type="hidden" id="txtCaptcha" /></label> </div><!-- End Kode --> <div class="checker"><span id="spryconfirm1"> <label for="checkit"></label> <input type="text" name="checkit" id="checkit" /> <span class="confirmRequiredMsg">Can't be empty.</span><span class="confirmInvalidMsg">That don't match.</span></span></div><!-- End checker --> </div><!-- End Textboxer --> </div><!-- End ContactLeft --> <div id="contactright"> <div class="textboxer"><span id="sprytextarea1"> <label for="message"></label> <textarea name="message" cols="45" rows="5" class="mssager" id="message"></textarea> <span class="textareaRequiredMsg">A value is required.</span></span></div><!-- End Textboxer --> <div class="textboxer"> <input type="submit" name="sendit" id="sendit" value="send your message" /> </div><!-- End Textboxer --> </div><!-- End ContactRight --> </form>
While the form processor is as shown bellow
<?php $mailto = '[email protected]'; // insert the email address you want the form sent to //$returnpage = 'thanks.php'; // insert the name of the page/location you want the user to be returned to// $sitename = '[siteripe.com]'; // insert the site name here, it will appear in the subject of your email /* Do not edit below this line unless you know what you're doing */ $name = $_POST['name']; $email = $_POST['email'] ; $subject = $_POST['subject']; $message = $_POST['message']; $phone = $_POST['phone']; $env_report = $_POST['env_report']; $anti_tamper = $_POST['anti_tamper']; // Mail header removal function remove_headers($string) { $headers = array( "/to\:/i", "/from\:/i", "/bcc\:/i", "/cc\:/i", "/Content\-Transfer\-Encoding\:/i", "/Content\-Type\:/i", "/Mime\-Version\:/i" ); $string = preg_replace($headers, '', $string); return strip_tags($string); } // Pick up the cleaned form data $name = remove_headers($_POST['name']); $email = remove_headers($_POST['email']); $topic = remove_headers($_POST['topic']); $comments = remove_headers($_POST['comments']); if (!$name) { print("<strong>Error:</strong> Please provide your name.<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } if (!$email) { print("<strong>Error:</strong> Please provide an email address.<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } if (!$subject) { print("<strong>Error:</strong> Please provide a subject.<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } if (!$phone) { print("<strong>Error:</strong> Please provide a Phone number<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } if (!$message) { print("<strong>Error:</strong> Please provide a Message<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $email)){ print("<strong>Error:</strong> this email address is not in a valid format.<br/><br/><a href='javascript:history.go(-1)'>Back</a>"); exit; } $message = "\n$name submitted the following message:\n\n$message\n\n$name's contact details are as follows:\n\nName: $name\nPhone Number: $phone\nEmail Address: $email\nUser IP: $env_report\nTamper Proof: $anti_tamper\n"; mail($mailto, "$subject", $message, "From: $email"); ?> <?php get_header(); ?>
- The topic ‘Form Mailer isue’ is closed to new replies.