Jump to content

need help sending email with recaptcha?


flix_is_here22

Recommended Posts

hii have a contact form and i put recapthca from google for antispam. i have a problem when sending email and check recaptcha. This is html file.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>asd</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script type="text/javascript"> var RecaptchaOptions = { theme : 'blackglass' };</script><script type="text/javascript">function show_alert(){var nama = document.form.name.value;var telp = document.form.phonenumber.value;var email1 = document.form.email.value;var koment = document.form.comment.value; if(nama==""){ alert("Please input your name!"); document.form.name.focus(); } else if(telp==""){ alert("Please input your phone number!"); document.form.phonenumber.focus(); } else if(isNaN(telp)==true){ alert("Please input your phone number correctly!"); document.form.phonenumber.focus(); } else if(email1==""){ alert("Please input your email!"); document.form.email.focus(); } else if(document.form.email.value.search(/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)){ alert("Please input your email correctly!"); document.form.email.focus(); } else if(koment==""){ alert("Please input your comment or question!"); document.form.comment.focus(); }}</script></head><body> <form method="post" name="form" action="verify.php" > <?php require_once('recaptchalib.php'); $publickey = "mypublickey"; echo recaptcha_get_html($publickey); ?> <table> <tr><td>Name *</td><td><input type="text" name="name" /></td></tr> <tr><td>Address</td><td><input type="text" name="address" /></td></tr> <tr><td>Phone Number *</td><td><input type="text" name="phonenumber" /></td></tr> <tr><td>Email *</td><td><input type="text" name="email" /></td></tr> <tr><td>Category</td><td><select name="category"> <option>Appointment</option> <option>Complain</option> <option>General Feedback</option> <option>Other</option> </select></td></tr> <tr><td>Comment / Question *</td><td><textarea rows="10" cols="20" name="comment"></textarea></td></tr> <tr><td colspan="2"><input type="submit" name="btn" value="Send" onClick="show_alert()" /> <input type="reset" name="reset" value="Reset" /></td></tr> </table> <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=mypublickey"></script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=mypublickey" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> </noscript> </form></body></html> This is php file.<?php$name=$_POST["name"];$address=$_POST["address"];]$phone=$_POST["phonenumber"];$email=$_POST["email"];$category=$_POST["category"];$comment=wordwrap($name."\r\n".$address."\r\n".$phone."\r\n".$email."\r\n".$_POST["comment"],70);require_once('recaptchalib.php');$privatekey = "myprivatekey";$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);if (!$resp->is_valid) {// What happens when the CAPTCHA was entered incorrectlydie ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); header("Copy of recaptcha.html");}else { mail(contactus@asd.com,$category,$comment) echo "Message has been sent....."}?> all of this code i following step by step from https://developers.google.com/recaptcha/ but this isn't work... any suggestion??need help...... :facepalm:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...