Ok so i run in to a spot of bother,
Up on user submitting comments to my site i had no issues i dident need to use anything like recapatcha, but now spammers alert!
The script i am using works perfectly when a user submits, then i added recapatcha to it, which i added with no problems atall, until i run the script testing it on the site. I dont see no errors in the recapatcha script so it tells me there is something wrong with my code. I did move the recapatch script around and made the recapatcha finish before it runs my code just to see if i could figure it out, when i put it before my code it all went through but of course the code was not secure with re. So when i drop my code inside the recapatcha server side code i pull out a
Server error
The website encountered an error while retrieving http://www.chulse.co.uk/output/addguestbook.php. It may be down for maintenance or configured incorrectly.
Could someone please take a look see if they cans spot the problem? thanks!
[php]
<?php require_once('../CP/Scripts/recaptchalib.php'); $privatekey = "6LeOVNMSAAAAAAXyYr8QlNkVs6zb-xC7JM-RhmiH"; $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 incorrectly die ("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 $dbservertype='mysql'; $servername='name'; // username and password to log onto db server $dbusername='dbname'; $dbpassword='dbpass'; // name of database $dbname='dbname'; //////////////////////////////////////// ////// DONOT EDIT BELOW ///////// /////////////////////////////////////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword){ global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } $email=$_POST['email']; $name=$_POST['name']; $country=$_POST['country']; $dtl=$_POST['dtl']; $status = "OK"; // setting the flag for form validation $msg=""; // error message string is blank // now let us check email address if (!stristr($email,"@") OR !stristr($email,".")) { $msg="Your email address is not correct"; $status="NOT OK"; } // Now let us check if name is entered or not if(strlen($name) < 2 ){ // if name is less than two char length $msg .="Please enter your name
"; $status="NOT OK"; } if($status<>"OK"){ // if form validation is not passed echo "
"; echo $msg. "
"; }else{ $tm=time(); // reading the time of entry // adding data to mysql database //first thing is to escape single quotes! $dtl = str_replace("'","\'",$dtl); //now process $rt=mysql_query("insert into guest_book(name,email,country,tm,dtl) values('$name','$email','$country','$tm','$dtl')"); echo mysql_error(); echo "Thank you for your comment! You will automaticly be redirected..."; //send e mail to self with the users e mail address for a thank you message! ?> <? $to = "[email protected]"; $subject = "Comment submission"; $message = $name . "\n\n" . $dtl . "\n\n" . $email; $from = $email; $headers = "From:" . $from; mail($to,$subject,$message,$headers); //now lets send an e mail to the user and thank them! $to = $email; $subject = "We want to thank you!"; $message = "You recently submited a review on www.chulse.co.uk. We want to thank you for taking the time to give us your feedback! it is greatly appriciated. If you have any questions at all please contact me using this e mail address or by using the contact form on the website. http://www.chulse.co.uk \n\n Cerris Hulse."; $from = "[email protected]"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); } } header('Refresh: 5; URL=../'); ?>
[/php]