TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-19-2012, 12:30 AM   #1 (permalink)
The Wanderer
 
Timms's Avatar
 
Join Date: May 2012
Posts: 6
Thanks: 2
Timms is on a distinguished road
Default 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=../');
  
?>
Timms is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
image upload script with watermark hitchy Absolute Beginners 0 08-12-2011 08:58 AM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
Random Avatar Script FaceDancer Script Giveaway 1 08-22-2008 05:47 AM
Script works and does what I want, but timeouts j4v1 General 1 06-04-2008 07:42 PM
hash() algorithm info script RobertK Script Giveaway 4 01-09-2008 03:00 PM


All times are GMT. The time now is 11:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design