hi everybody,
iam new to this website and php as well. i get public and private key from recaptcha i have problem in captcha where to post, can anybody help me. i'll be greatful

BEFORE PUTTING RECAPTCHA IN COMMENTS.PHP it worsk on page

<html>
<body bgcolor="000000" text="ffffff" >
<center>
<form  method = "POST" action = "<?php echo $_SERVER['PHP_SELF']; ?>">
name <br>  <input type = "text" name = "name"> <br>
email <br>  <input type = "text" name = "email"> <br>
location <br>  <input type = "text" name = "location"> <br>
message <br>  <textarea cols ="50" rows = "5" name = "message"> </textarea> <br>
<input type = "submit" value = "post">
<input type = "reset" value = "reset">
</form>
</center>
</body>
</html>


<?php
$time = time();
$name = htmlentities($_POST['name']);
$email = htmlentities($_POST['email']);
$location = htmlentities($_POST['location']);
$message = htmlentities($_POST['message']);
if($name && $email && $location && $message)
{
$con = mysql_connect("localhost","root",";");
$db = mysql_select_db("database",$con) or die("cannot connect database");
$sql = "INSERT INTO guest VALUES('','$time','$name','$email','$location','$message')";
$query = mysql_query($sql);
}
else
{
        echo "<center> <strong> please fill all form </strong> </center>";
}
?>

<?php
$con = mysql_connect("localhost","root",";");
$db = mysql_select_db("database") or die ("cannot connect db");
$sql = "select * from guest";
$query = mysql_query($sql);

while($data=mysql_fetch_array($query))
{
   $dbtime = date('d M Y @ h:i:s',$data['time']);
   $dbname = $data['name'];
   $dbemail = $data['email'];
   $dblocation = $data['location'];
   $dbmessage = $data['message'];
   echo "<hr>";

   echo $dbtime;
   echo "  ";
        echo "name: $dbname";
   echo "  ";
        echo "email: $dbemail";
   echo "  ";
        echo "location: $dblocation";
   echo "  ";
   echo "<br>";
   echo "<strong> $dbmessage </strong>";
}
?>

AFTER PUTTING RECAPTCHA IN COMMENTS.PHP

<html>
<body bgcolor="000000" text="ffffff" >
<center>
<form  method = "POST" action = "<?php echo $_SERVER['PHP_SELF']; ?>">
name <br>  <input type = "text" name = "name"> <br>
email <br>  <input type = "text" name = "email"> <br>
location <br>  <input type = "text" name = "location"> <br>
message <br>  <textarea cols ="50" rows = "5" name = "message"> </textarea> <br>
<form method="post" action="verify.php">
        <?php
          require_once('recaptchalib.php');
          $publickey = "xxxxxxxx"; // you got this from the signup page   
          echo recaptcha_get_html($publickey);
        ?>

<input type = "submit" value = "post">
<input type = "reset" value = "reset">
</form>
</center>
</body>
</html>


<?php
$time = time();
$name = htmlentities($_POST['name']);
$email = htmlentities($_POST['email']);
$location = htmlentities($_POST['location']);
$message = htmlentities($_POST['message']);

 <?php
  require_once('recaptchalib.php');
  $privatekey = "xxxxxxxx";
  $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
  }
  ?>

if($name && $email && $location && $message)
{
$con = mysql_connect("localhost","root",";");
$db = mysql_select_db("database",$con) or die("cannot connect database");
$sql = "INSERT INTO guest VALUES('','$time','$name','$email','$location','$message')";
$query = mysql_query($sql);
}
else
{
        echo "<center> <strong> please fill all form </strong> </center>";
}
?>

<?php
$con = mysql_connect("localhost","root",";");
$db = mysql_select_db("database") or die ("cannot connect db");
$sql = "select * from guest";
$query = mysql_query($sql);

while($data=mysql_fetch_array($query))
{
   $dbtime = date('d M Y @ h:i:s',$data['time']);
   $dbname = $data['name'];
   $dbemail = $data['email'];
   $dblocation = $data['location'];
   $dbmessage = $data['message'];
   echo "<hr>";

   echo $dbtime;
   echo "  ";
        echo "name: $dbname";
   echo "  ";
        echo "email: $dbemail";
   echo "  ";
        echo "location: $dblocation";
   echo "  ";
   echo "<br>";
   echo "<strong> $dbmessage </strong>";
}
?>

lastly my recaptcha doesnt work. can anybody figure me mistake out and help me. i'll be greatfull.

THANK YOU IN ADVANCE;

Member Avatar for diafol

It doesn't work. Can you be more specific? Do you get any error message at all?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.