Jump to content

CarlyBryan

New Members
  • Posts

    1
  • Joined

  • Last visited

CarlyBryan's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. HI recently we have been starting to recieved about 30 spam emails aday. I read that the issue was how my forms were submitting and that it kept bypassing the javascript. I found some code i could use at http://chrisplaneta.com/freebies/php_contact_form_script_with_recaptcha/ but i cannot seem to get the form to function correctly. It is supposed to email me once the form is validated but the email does not seem to be sending. Also i would like the form to redirect to a thank you page once it has been agreed. I did try but it kept telling me the headers had already been called. i am calling the page in with php include. Can you please advise the best way for me to relocate. I have attached a copy of my form.php page which has every thing on. I have also included the code at the bottom of this email Also i would appreciate any comments on what i can include on my form to limit the spammers <?php //If the form is submitted: if(isset($_POST['submitted'])) { //load recaptcha file require_once('captcha/recaptchalib.php'); //enter your recaptcha private key $privatekey = "6Ld5Df4SAAAAAKciqwDco8dfvBR15fGeFVXWcvCO"; //check recaptcha fields $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); //Check to see if the invisible field has been filled in if(trim($_POST['checking']) !== '') { $blindError = true; } else { //Check to make sure that a contact name has been entered $authorName = (filter_var($_POST['formAuthor'], FILTER_SANITIZE_STRING)); if ($authorName == ""){ $authorError = true; $hasError = true; }else{ $formAuthor = $authorName; }; //Check to make sure sure that a valid email address is submitted $authorEmail = (filter_var($_POST['formEmail'], FILTER_SANITIZE_EMAIL)); if (!(filter_var($authorEmail, FILTER_VALIDATE_EMAIL))){ $emailError = true; $hasError = true; } else{ $formEmail = $authorEmail; }; //Check to make sure the subject of the message has been entered $msgSubject = (filter_var($_POST['formSubject'], FILTER_SANITIZE_STRING)); if ($msgSubject == ""){ $subjectError = true; $hasError = true; }else{ $formSubject = $msgSubject; }; //Check to make sure content has been entered $msgContent = (filter_var($_POST['formContent'], FILTER_SANITIZE_STRING)); if ($msgContent == ""){ $commentError = true; $hasError = true; }else{ $formContent = $msgContent; }; // if all the fields have been entered correctly and there are no recaptcha errors build an email message if (($resp->is_valid) && (!isset($hasError))) { $emailTo = 'carlycyber@hotmail.co.uk'; // here you must enter the email address you want the email sent to $subject = 'A new message from: immigration solicitors Manchester' ; $body = "Name :formAuthor \n\nEmail: $formEmail \n\nTelephone :formSubject \n\nContent: $formContent \n\n$formAuthor"; // This is the body of the email $headers = 'From: <'.$formEmail.'>' . "\r\n" . 'Reply-To: ' . $formEmail . "\r\n" . 'Return-Path: ' . $formEmail; // Email headers // Email headers //send email mail($emailTo, $subject, $body, $headers); // set a variable that confirms that an email has been sent $emailSent = true; } // if there are errors in captcha fields set an error variable if (!($resp->is_valid)){ $captchaErrorMsg = true; } } } ?> <?php // if the page the variable "email sent" is set to true show confirmation instead of the form ?> <?php if(isset($emailSent) && $emailSent == true) { ?> <?php $message = "Thank you. Your form has been submitted and a member of our team will contact you shortly.This website is developed for generating immigration enquiries in your area and it is not a law firm, your enquiries will be passed on to a solicitor.We confirm that this website does not belong to a law firm and we have no physical office in your county. Our solicitors are able to provide immigration services all over the UK because they provide a Virtual Service.Responses to your legal enquiries and the legal opinion given to you would be provided by a qualified UK Immigration Solicitor. If you decide to proceed with the solicitor, your matter will be dealt with under a Law firm regulated by the Solicitors Regulatory Authority."; echo "<script type='text/javascript'>alert('$message');</script>"; /*echo "<script language='javascript'> window.location('http://www.immigrationsolicitorsmanchesteruk.co.uk/thankyou.php') </script>";*/ ?> <p>Thank you. Your form has been submitted and a member of our team will contact you shortly.This website is developed for generating immigration enquiries in your area and it is not a law firm, your enquiries will be passed on to a solicitor.We confirm that this website does not belong to a law firm and we have no physical office in your county. </p> <?php } else { ?> <?php // if there are errors in the form show a message ?> <?php if(isset($hasError) || isset($blindError)) { ?> <p><strong>Im sorry. There was an error submitting the form. Please check all the marked fields and try again.</strong></p> <?php } ?> <?php // if there are recaptcha errors show a message ?> <?php if ($captchaErrorMsg){ ?> <p><strong>The recaptcha was not entered correctly. Please try again.</strong></p> <?php } ?> <?php // here, you set what the recaptcha module should look like // possible options: red, white, blackglass and clean // more infor on customisation can be found here: http://code.google.com/intl/pl-PL/apis/recaptcha/docs/customization.html ?> <script type="text/javascript"> var RecaptchaOptions = { theme : 'blackglass' }; </script> <?php // this is where the form starts // action attribute should contain url of the page with this form // more on that you can read here: http://www.w3schools.com/TAGS/att_form_action.asp ?> <form id="contactForm" action="" method="post"> <p> <strong>Full Name</strong><br/> <input class="requiredField <?php if($authorError) { echo 'formError'; } ?>" type="text" name="formAuthor" id="formAuthor" value="<?php if(isset($_POST['formAuthor'])) echo $_POST['formAuthor'];?>"size="25" /></p> <p> <strong>Email </strong><br/> <input class="requiredField <?php if($emailError) { echo 'formError'; } ?>" type="text" name="formEmail" id="formEmail" value="<?php if(isset($_POST['formEmail'])) echo $_POST['formEmail'];?>" size="25" /> </p> <p> <strong>Telephone </strong><br/> <input class="requiredField <?php if($subjectError) { echo 'formError'; } ?>" type="text" name="formSubject" id="formSubject" value="<?php if(isset($_POST['formSubject'])) echo $_POST['formSubject'];?>" size="25" /> </p> <p> <strong>Please give us some information about your enquiry</strong><br/> <textarea class="requiredField <?php if($commentError) { echo 'formError'; } ?>" id="formContent" name="formContent" cols="25" rows="5"><?php if(isset($_POST['formContent'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['formContent']); } else { echo $_POST['formContent']; } } ?></textarea></p> <?php // this field is visible only to robots and screenreaders // if it is filled in it means that a human hasn't submitted this form thus it will be rejected ?> <div id="screenReader"> <label for="checking"> If you want to submit this form, do not enter anything in this field </label> <input type="text" name="checking" id="checking" value="<?php if(isset($_POST['checking'])) echo $_POST['checking'];?>" /> </div> </div> <?php // load recaptcha file require_once('captcha/recaptchalib.php'); // enter your public key $publickey = "6Ld5Df4SAAAAANFKozja9bUlDziJ92c31DDt1j6k"; // display recaptcha test fields echo recaptcha_get_html($publickey); ?> <input type="hidden" name="submitted" id="submitted" value="true" /> <?php // submit button ?> <input type="submit" value="Send Message" tabindex="5" id="submit" name="submit"> </form> <?php } // yay! that's all folks! ?> form issue.txt
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.