Jump to content

reCAPTCHA


AidaPus

Recommended Posts

Hi,

Could anyone help me pls? I wanted to help my father get rid of these nasty thingy's, http://www.galleri1897.no/viewguestbook.php, and have tried to get the reCAPTCHA to work. I followed the instruction from this site: http://recaptcha.net/plugins/php/. and my code then looks like this (the only thing I did different was to put the reCAPTCHA echo another place, -if I didnt, the page did not show at all, and I found this tips on the net). I have highlited the reCAPTA code:

 

First file, -the one that is supposed to show the reCAPTA box in http://www.galleri1897.no/guestbook.php

 

 

<?php

require_once('recaptchalib.php');            //denne filen må legges i samme mappe som guestbook.php

$publickey = "xxxxxx";        // you got this from the signup page  (REMOVED of course..)

 

?>

<?php

 

//skjema for gjestebok. her har gjester mulighet til å skrive kommentarer i gjesteboken. data som tastes inn blir sendt videre til addguestbook.php

//i tillegg kan man trykke på 'vis gjestebok' kanppen. der kan man lese alle kommentarer som ble lagt til.

require('page.php');

$art_side = new Page();

$art_side->innhold ='

<table width="900" border="0" bgcolor="white"  align="center" cellpadding="0" cellspacing="0">

<tr>

<td><p class="middle">Gjestebok for Galleri 1897 <p></td></tr>

 

</table>

<table width="900" height="150" border="0" bgcolor="white"  align="center" cellpadding="0" cellspacing="0">

<tr>

<td align="center" ><strong><a href="viewguestbook.php">Vis gjestebok</a> </strong></td>

</tr>

 

 

 

<tr>

<td align="center">

<?php

echo recaptcha_get_html($publickey);

?>

</td>

</tr>

 

 

 

 

 

</table>

 

<table width="900" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="white">

<tr>

<form id="form1" name="form1" method="post" action="addguestbook.php">

<td>

<table width="700" border="0" cellpadding="0" cellspacing="0" bgcolor="white">

<tr>

<td align="right"><p>Navn</p></td>

<td width="14"></td>

<td width="350"><input name="name" type="text" id="name" size="40" /></td>

</tr>

<tr>

<td align="right"><p>Email</p></td>

<td></td>

<td><input name="email" type="text" id="email" size="40" /></td>

</tr>

<tr>

<td valign="top" align="right"><p>Kommentar</p></td>

<td valign="top"></td>

<td><textarea name="comment" cols="40" rows="10" id="comment"></textarea></td>

</tr>

 

 

<tr>

<td> </td>

<td> </td>

<td><input type="submit" name="Submit" value="Send" /> <input type="reset" name="Submit2" value="Nullstill" /></td>

</tr>

</table>

</td>

</form>

</tr>

 

 

 

</table>

';

$art_side->Show();

  ?>

 

***************************************************************************************

 

 

The second file, that is supposed to send the info from reCAPTA, among other things:

 

 

<?php

 

/* data som gjesten taster inn paa 'guestbook.php' blir her sendt til databasen. I tillegg faar man kommentar om at melidngen har blitt registrert og

mulighet a lese gjestebok.

*/

 

 

//***********reCAPTCHA kode**************

 

//Denne MÅ ligge i starten av dokumentet, ellers vil ikke sjekkfunksjonen virke.

//Koden under sjekker om brukeren har skrevet inn riktige symboler.

//Koden for å generere, vise og sende symbolene ligger i filen guestbook.php

//For å fungere må filen recaptchalib.php ligge i samme mappe som guestbook.php

//Blir guestbook.php lagt i en annen mappe, må dette vises i koden i nevnte fil (på samme måte som linker)

require_once('recaptchalib.php');

$privatekey = "XXXXX";  ///REMOVED of course

$resp = recaptcha_check_answer ($privatekey,

                                $_SERVER["REMOTE_ADDR"],

                                $_POST["recaptcha_challenge_field"],

                                $_POST["recaptcha_response_field"]);

 

if (!$resp->is_valid) {

  die ("The reCAPTCHA code wasn't entered correctly. Go back and try it again." .

      "(reCAPTCHA said: " . $resp->error . ")");

}

//***********Slutt på reCAPTCHA koden*********

 

 

include('connect.php');

 

$tbl_name="guestbook"; // Table name

 

$datetime=date("y-m-d h:i:s"); //date time

$name=$_POST['name'];

$email=$_POST['email'];

$comment=$_POST['comment'];

 

$sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";

$result=mysql_query($sql);

 

require('page.php');

 

$art_side = new Page();   

   

 

                     

//check if query successful

if($result){

$art_side->innhold = '

<table align="center" width="900" height="350" cellpadding="0" border="0" bgcolor="white">

<tr align="center"><td>

        <p class="middle">Din melding er lagt til</p></td>

</tr>

 

<tr align="center"><td>

        <p><a href="viewguestbook.php">Vis gjestebok</a></p></td>

      </tr>

 

</table>';

}

//viss feil, skriv feilmelding

else {

$art_side->innhold = '<table width="900" height="200" cellpadding="0" border="0" bgcolor="white">

<p class="middle">"Det skjedde en feil"</p>

</table>';

}

 

mysql_close();

$art_side->Show();

?>

 

 

************************************************************************************************

 

 

I was wondering if the public and private key where supposed to be inside this type of brackets:  "xxx "

 

I allso wondered if it could have something to do with the first file, -before I put in the new reCAPTCHA code, I had a "handler" that took care of sucsessful sending of data to the guestbook aso.

 

Please excuse my type error, -from Norway....    ;)

 

Hope anybody can help!!!

 

Thanks a lot for reading this

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I used reCaptcha on my site but found that it was hard to read by humans as well as machines.  I loved the idea of reCaptcha using the information to digitise books but have found that since changing to another captcha we are getting more form completions.

 

the one I now use is available here http://www.white-hat-web-design.co.uk/articles/php-captcha.php

 

I don't think it is particularly secure but it is easy to negotiate for the user and will slow down all but persistant hackers. You can see it in action on my site at

http://www.jackiebrownmedical.ie/applyhere.php?url=apply&jobref=JB-0807-9

 

The size and number of letters required can be changed in the script.

Hope you find this helpful.

Ian.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.