TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   getting error when put recapatcha in to script! need help (http://www.talkphp.com/general/6376-getting-error-when-put-recapatcha-script-need-help.html)

Timms 09-19-2012 12:30 AM

getting error when put recapatcha in to script! need help
 
I have a script input that allows you to add to the site guest book, which connects and sends data to the MYSQL data-base. The data base and everything else works fine, if i dont add the reCapatch script everything works perfectly... but then when i add reCapatch i pull out a 500 error, and for the life of me cant figure out why. Could you guys take a look and see if you can spot the problem! i am guessing its not reCapatcha causing the problem but something in my custom code for the data thanks

here is my script:

PHP Code:

<?php
require_once('location/recaptchalib.php');
  
$privatekey "my private key";
  
$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='sname';
// username and password to log onto db server
$dbusername='uname';
$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="<center>Your email address is not correct</center><BR>";
$status="NOT OK";
}
// Now let us check if name is entered or not 
if(strlen($name) < ){  // if name is less than two char length
$msg .="<center>Please enter your name</center><BR>";
$status="NOT OK";
}
if(
$status<>"OK"){ // if form validation is not passed
echo "<BR><BR>";
echo 
$msg"<br><center><input type='button' value='Retry' onClick='history.go(-1)'></center><br><br><br>";
}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!

  
}
header('Refresh: 5; URL=../');
  
?>


shui1880 11-13-2012 11:47 AM

If you are a music enthusiast longing to listen to your favorite music for extended periods of time, Monster headphones fit the bill perfectly. They have been designed to ensure a thrilling music experience for extended periods without causing discomfort or pain to the user. An interesting feature of Dr Dre Headphones the Monster Beats is that you don need to dig into your pocket to pause or press mute. A quick tap is what it takes to do the needful. You can choose from a variety of eye-catching accessories to complement dr dre beats these headphones. Browse the web to navigate an exotic range of stunning accessories online. They are http://www.drdreheadphones-sale.net available at astonishingly competitive prices.


All times are GMT. The time now is 07:31 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0