Foosicle Posted June 24, 2011 Share Posted June 24, 2011 Today's pain: http://code.google.com/apis/recaptcha/docs/php.html Getting the above to function on my site.. All aid appreciated. Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/ Share on other sites More sharing options...
WebStyles Posted June 24, 2011 Share Posted June 24, 2011 well that's a bit vague, don't you think? What exactly have you done so far, and what has gone wrong? Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234415 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 So far I have visible: 1. the form 2. the recaptcha working on mail() func Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234420 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 <table> <tbody bgcolor="#EFEFF5"> <form name="helpform" method="post" action=""> <div id="recaptcha"> <?php require_once('include/recaptchalib.php'); $publickey = "**************************** "; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </div> <tr id="contactform"> <td>Your Email: </td> <td> <input name="FROM" type="text" size="40" maxlength="30" value="<?php echo stripslashes(trim(htmlentities($FROM))) ?>" onFocus="this.value==this.defaultValue?this.value='':null"> </td> </tr> <tr id="contactform"> <td>First Name: </td> <td> <input name="fname" type="text" size="40" maxlength="20" value="<?php echo stripslashes(trim(htmlentities($fname)))?>" onFocus="this.value==this.defaultValue?this.value='':null"> </td> </tr> <tr id="contactform"> <td>Last Name: </td> <td> <input name="lname" type="text" size="40" maxlength="20" value="<?php echo stripslashes(trim(htmlentities($lname)))?>" onFocus="this.value==this.defaultValue?this.value='':null"> </td> </tr> <tr id="contactform"> <td>Message: </td> <td> <textarea name="message" rows="5" cols="31" maxlength="200" value="<?php echo stripslashes(trim(htmlentities($message)))?>" wrap="physical"></textarea> </td> </tr> </tr> <tr> <td> <input type="submit" value="Submit" action="mail()"> </td> </tr> </form> Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234422 Share on other sites More sharing options...
WebStyles Posted June 24, 2011 Share Posted June 24, 2011 Let me ask that again: What exactly is the problem? What has gone wrong? What errors are you getting? What is not working? Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234424 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 here comes the error my verify file looks like: <?php $errors = array(); //READ the user recaptcha require_once('recaptchalib.php'); $privatekey = "******************************"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); //READ the posted form data $fromemail = $_POST['fromemail']; $fname = $_POST['fname']; $lname = $_POST['lname']; $message = $_POST['message']; //VALIDATE form data exists if(!isset($frommail) || !isset($fname) || !isset($lname) || !isset($message)){ echo 'We are sorry, but there appears to be a problem with the form you submitted.'; }else{ echo 'success'; } $fromemail = stripslashes($fromemail); $fname = stripslashes($fname); $lname= stripslashes($lname); $message = stripslashes($message); $fromemail = trim(htmlentities($fromemail)); $fname = trim(htmlentities($fname)); $lname= trim(htmlentities($lname)); $message = trim(htmlentities($message)); //VALIDATE !errors if (!empty($errors)){ redirect_to("http://www.*******.com/index.php"); } //CREATE the email form data $to = "customerservice@*******.com"; $subject = $fname . " " . $lname; $headers = "From: " . $fromemail; if (!$resp) { // What happens when the CAPTCHA was entered incorrectly echo ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); }else { // Your code here to handle a successful verification echo "SUCCESS!"; } mail($to, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234472 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 //VALIDATE form data exists if(!isset($frommail) || !isset($fname) || !isset($lname) || !isset($message)){ echo 'We are sorry, but there appears to be a problem with the form you submitted.'; }else{ echo 'success'; } This gives me err. 'We are sorry, but there appears to be a problem with the form you submitted.' Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234473 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 Found this error to be: TYPO!! $fromemail = $_POST['fromemail']; if(!isset($frommail) || Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234481 Share on other sites More sharing options...
Foosicle Posted June 24, 2011 Author Share Posted June 24, 2011 In an effort to validate safe data I have attempted to implement stripslashes, trim, and htmlentities... How does that code look? $fromemail = stripslashes($fromemail); $fname = stripslashes($fname); $lname= stripslashes($lname); $message = stripslashes($message); $fromemail = trim(htmlentities($fromemail)); $fname = trim(htmlentities($fname)); $lname= trim(htmlentities($lname)); $message = trim(htmlentities($message)); Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234483 Share on other sites More sharing options...
Foosicle Posted June 25, 2011 Author Share Posted June 25, 2011 $recaptcha_challenge_field = $_POST["recaptcha_challenge_field"]; $recaptcha_response_field = $_POST["recaptcha_response_field"]; echo $recaptcha_challenge_field; echo $recaptcha_response_field; so according to this.. they are not getting posted. strange because I have no way of seeing the code in the form other than : <?php require_once('include/recaptchalib.php'); $publickey = "************************-******* "; // you got this from the signup page echo recaptcha_get_html($publickey); ?> So if that is not displaying anything.. should i worry? and how? Link to comment https://forums.phpfreaks.com/topic/240315-php-and-recaptcha/#findComment-1234554 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.