le 03/07/2009 à 01:12
Codelyokodd
J'ai un problème, je n'arrive pas à faire fonctionner mon Captcha, voici mon code :
livreor.php
<?php
<form method="post" action="livreor.php">
<p>Que pensez-vous de Simsophiles? Exprimez-vous ici en laissant un petit message.</p>
<p>
<center><h3>Pseudo :</h3> <input name="pseudo" /></center><br />
<center><h3>Message :</h3><br />
<textarea name="message" rows="8" cols="35"></textarea></center><br />
<center><script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LcZKgcAAAAAAG3DrfByjni9nZXFoR-vj9im2lR7 "></script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=6LcZKgcAAAAAAG3DrfByjni9nZXFoR-vj9im2lR7 " height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript> <em>Type the two words = Recopiez les deux mots</em></center><br /><br />
<center><input type="reset" value="Tout Effacer" /><input type="submit" value="Envoyer" /></center>
</p>
</form>
<p class="pages">
<?php
mysql_connect("???", "????", "????");
mysql_select_db("?????");
if (isset($_POST['pseudo']) AND isset($_POST['message']))
{
$pseudo = mysql_real_escape_string(htmlspecialchars($_POST['pseudo']));
$message = mysql_real_escape_string(htmlspecialchars($_POST['message']));
$message = nl2br($message);
$privatekey = "6LcZKgcAAAAAAHeC40a0lHva-wOINuw_wv_TpE8X";
$resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
{
die("Le captcha entré est invalide. Veuillez-recommencer" . "(Captcha : " . $resp->error . ")");
}
else
{
mysql_query("INSERT INTO livreor VALUES('', '" . $pseudo . "', '" . $message . "')");
}
}
$nombreDeMessagesParPage = 10;
$retour = mysql_query('SELECT COUNT(*) AS nb_messages FROM livreor');
$donnees = mysql_fetch_array($retour);
$totalDesMessages = $donnees['nb_messages'];
$nombreDePages = ceil($totalDesMessages / $nombreDeMessagesParPage);
echo 'Page : ';
for ($i = 1 ; $i <= $nombreDePages ; $i++)
{
echo '<a href="livreor.php?page=' . $i . '">' . $i . '</a> ';
}
?>
</p>
<?php
if (isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$premierMessageAafficher = ($page - 1) * $nombreDeMessagesParPage;
$reponse = mysql_query('SELECT * FROM livreor ORDER BY id DESC LIMIT ' . $premierMessageAafficher . ', ' . $nombreDeMessagesParPage);
while ($donnees = mysql_fetch_array($reponse))
{
echo '<p><strong>' . $donnees['pseudo'] . '</strong> a écrit :<br />' . $donnees['message'] . '</p>';
}
mysql_close();
?>