Hi!
I am going mad, -I am not that familiar with php yet, but know a little basic programming.
I am receiving a lot of spam i our guestbook http://www.galleri1897.no/viewguestbook.php and wanted now to implement reCaptcha.

I got the keys, and actually got it to show in the right top corner once (allthough i dont remember where I then put the eco), but as it is now, the reCaptcha-box does not show at all!

Can anyone help a newbie here? This is how my code is now (I have left out the private and public keys)

Hope anyone can HELP!!!! Have been reading around the net for two days now!!!

<?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');

require_once('recaptchalib.php');
define('PUBLIC_KEY',  xxxxxxxxxxxxxxxxxxx');
 define('PRIVATE_KEY', 'xxxxxxxxxxxxxxxxxx');

$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>
</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 colspan="3" align="center">
<?php
echo recaptcha_get_html( PUBLIC_KEY );
  ?>
//ThisTestText is showing on my site where I wanted the box to be
</td>
</tr>

<tr>
<td>&nbsp;</td>
<td>&nbsp;</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();
  ?>

Recommended Answers

All 3 Replies

Hi again,
is there really noone who can help me? I'm loosing the rest of my hair here.... :'(

First off, I would suggest you delete all that spam from your guestbook.

Second, what is in recaptchalib.php? If there's something wrong, I would suggest you look at the page you included.

First off, I would suggest you delete all that spam from your guestbook.

Second, what is in recaptchalib.php? If there's something wrong, I would suggest you look at the page you included.

Hi, and thank you for your reply!
I have been working on this ever since i posted my first plee, and have finally found a way to get the box to show...
I think it was due to the use of single quotes to display the content of the page (I havent made it myself, -some students have helped my father and his gallery to a better homepage, but now I keep finding probs with it, like secure passwords, registering to the art-club aso, but one thing before the other!).

I have made a function that gives a variable the data of the box, and then I could "part" the single quotes in the code and add

. $RECAPTCHA_BOKS .

in the middle.

It is 06:30 here in Norway now, so I have to have a look at the submit-page tomorrow :zzz:

But if you have a more neat way to do this, and if you see some "bad" programming as such, I would really appretiate your help!! :-)

Here is the code as it is now:

<?php
require('page.php');

require_once('recaptchalib.php');
define('PUBLIC_KEY',  'xxxxxxxxxxxxxxxx');
//This is the function for assigning the box to a var:
function assignToVar(){
$haba = recaptcha_get_html( PUBLIC_KEY );
return $haba;
}
$RECAPTCHA_BOKS=assignToVar();

$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>
</tr>
<tr>
<td><p class="middle">Under oppgradering! Velkommen tilbake!<p></td></tr>
</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>
</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>&nbsp;</td>
<td>&nbsp;</td>
<td>'. $RECAPTCHA_BOKS .'</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</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();
  ?>

And this is the page.php that is required, which the students made:

<?php
class Page
{

  // attributter
  public $innhold;
  public $innhold2;
  public $knapper = array('Startside' => 'index.php',
			    					'Utstillinger' => 'utstillinger.php',
			   					 'Kunstnere' => 'kunstnere.php',
                     'Kunstklubb' => 'kunstklubb.php',
			    						'Gjestebok' => 'guestbook.php',
                     'Om Oss' => 'kontakt.php'
                           );
  

  public function __set($navn, $verdi)
  {
    $this->$navn = $verdi;
  }
  
  public function Show()
  {
  	$this->ShowFirst();
    $this->ShowTittel();
    $this->ShowHeader();
    $this->ShowMenu($this->knapper);
    echo $this->innhold;
	echo $this->innhold2;
    $this->ShowFooter();
    
  }
  public function ShowFirst()
  {
  	echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//NB\">
     	<html xmlns = \"http://www.w3.org/1999/xhtml\" xml:lang=\"nb\"> ";
    	echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />";
	echo "<meta http-equiv='Content-Style-Type' content='text/css' />";
	echo "<link href='stilark.css' rel='stylesheet' type='text/css' />";
	echo "<html>\n<head>\n";
  }  	

  public function ShowTittel()
  {
    echo "<title> Galleri 1897 </title>";
  }

  

public function ShowHeader()
  {
  
?></head><body>

<table align="center" width="900" cellpadding = '0' cellspacing = '0'>
  <td align="center"><img src='header.gif'></td>
</table>

<?
  }

  public function ShowMenu($knapper)
  {
echo "<div class='knapp'><table align='center' width = '900' cellpadding = '0' cellspacing = '0'>\n";
    echo " <tr>\n";

    //bergener stoerrelsen paa knappene
    $bredde = 100/count($knapper);

    foreach ($knapper as $navn=>$url)
    {
     $this->ShowKnapp($bredde, $navn, $url,
                             !$this->AktuallUrl($url));
    }
    echo " </tr>\n";
    echo "</table>\n</div>";
  }
  
  

  public function AktuallUrl($url)
  {
    if(strpos($_SERVER['PHP_SELF'], $url)==false)
    {
      return false;
    }
    else
    {
      return true;
    }
  }

  public function ShowKnapp($bredde, $navn, $url, $active = true)
  {
  
    if($active)
    {
      echo "<div class='knapp'><td width = '".htmlentities($bredde)."%'>
            <a href = '".htmlentities($url)."'>
           </a>
            <a href = '".htmlentities($url)."'><span class='menu'>$navn</span></a></td>";
    }
    else
    {
     echo "<div class='knapp'><td width = '".htmlentities($bredde)."%'>          
           <span class='active' >$navn</span></td>";
    }
  
  }
  
  
  
    public function ShowFooter()
  {
?>

<table align="center" width="900" cellpading="0" cellspacing="0" border="0">
      <td><p class="foot"><a href="start.php">Galleri 1897</a></p></td><td><p class="small" align="center"><a href="login.php">Admin</a></p>
      </td></tr>
    </table>
   </body></html>
<?
  }
  
  public function Loggut($name)
  {
?>
<table align="center" width ="900" cellpadding ="0" cellspacing ="0">
   <td>
   <form id="loggut" name ="loggut" method="post" action="loggut.php">
   <?php echo "<p class=\"little\">Du er logget inn som ".$name.'  '. "<input type='submit' name='loggut' value='Logg ut' /></p>" ?>
   </form>
   </td>
   </table>
<?
  }
}

 class AdminPage extends Page
  {
    private $knapper2 = array('Ny Kunstner' => 'nykunstner.php',
    														'Rediger Kunstner' => 'redigerkunstner.php',
                                'Nye Bilder' => 'nye_bilder.php',
                                'Rediger Bilder' => 'redbilder.php',
                                'Nytt Medlem' => 'nymedlem.php',
                                'Ny Bedrift' => 'nybedrift.php',
                                'Rediger Bedrift' => 'redklubb.php',
                                'Legg Til Artikkel' => 'tekst.php',
                                'Rediger Artikkel' => 'velgartikkel.php',
                               );
                               
     public $name= 'Admin';                           
    public function Show()
    {
      $this->ShowFirst();
      $this->ShowTittel();
      $this->ShowHeader();
      $this->ShowMenu($this->knapper);
      $this->Test();
      $this->Loggut($this->name);
       $this->ShowMenu($this->knapper2);
      echo $this->innhold;
      $this->ShowFooter();
    }
  }
  
  class KlubbPage extends Page
  {
    private $knapper3 = array('Hovedside' => 'mainklubb.php',
    													'Bilder pa tilbud' => 'tilbud.php',
    													'Informasjon' => 'artikler.php',
                               );
    public function Show()
    {
      $this->ShowFirst();
      $this->ShowTittel();
      $this->ShowHeader();
      $this->ShowMenu($this->knapper);
      $this->Loggut();
       $this->ShowMenu($this->knapper3);
      echo $this->innhold;
      $this->ShowFooter();
    }
  }
  
  class BedriftPage extends Page
  {
  private $knapper4 = array('Hovedside' => 'bedriftklubb.php',
  													'Bilder pa tilbud' => 'bedtilbud.php',
  													'Deres bilder' => 'bedbilder.php',
  													'Informasjon' => 'bedartikler.php',
  													);
  
  public function Show() 
  {
      $this->ShowFirst();
      $this->ShowTittel();
      $this->ShowHeader();
      $this->ShowMenu($this->knapper);
      $this->Loggut();
       $this->ShowMenu($this->knapper4);
      echo $this->innhold;
      $this->ShowFooter();
    }
  }
  
?>
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.