Bonsoir,
svp j'ai un formulaire de suppression et je voudrais lui ajouter un captcha,
j'ai trouver ce captcha sur le net http://www.maheshchari.com/captcha-php-tutorial/
mais j'ai pas su l'intégrer lors de clic sur le bouton de mon formulaire
j'ai essayer ceci mais la suppression passe que le captcha est juste ou non ou que je l'ai saisie ou non
<div id="apDiv5">
<?php
session_start();
if(!isset($_SESSION['login'])||!isset($_SESSION['password'])||!isset($_SESSION['profil']))
{
print "<script>";
print "page='index.php';";
print"setTimeout('self.location=page',0);";
print"</script>";
}
?>
<?php
/*
*we create the generel form with image src to php_captcha.php and "captcha_key" stored in session.
*when user submits the form we check for it.
*and run routine form validations for email ,name ...etc
*Author:G mahesh chari (http://www.maheshchari.com)
*/
@session_start();
$errors=array();
if(isset($_POST['Submit'])){ //if user submits the form
if($_SESSION['captcha_key']!=$_POST['captchacode'])
//check whether stored in session value with the user submitted values
$errors[]="Invalid Captcha Code.";
if($_POST['yourname']=='')
$errors[]="Name is Required.";
//everything going fine user submitted real data and the user is real user not bot
//proces the data what we want to form data.
if(count($errors)==0){
echo "Captcha and Name is verified.";
}
}
?>
<div id="apDiv1">
<form action="ciblesupp.php" method="get" id="f1" name="myform">
<fieldset id="container">
<legend>Suppression</legend>
<span class="blanc">Choisir un utilisateur :</span>
<select name="username" id="username">
<option>-Choisissez-</option>
<?php
$reponse = $bdd->prepare('SELECT username FROM user');
$reponse->execute();
while ($donnees = $reponse->fetch())
{
echo'<option value="'.$donnees['username'].'">'.$donnees['username'].'</option>';
}
?>
</select>
<table width="500" border="2">
<tr>
<th colspan="2">Register
<?php
/* if user submits and any errors exists we display them for user. */
if(isset($_POST['Submit']) and count($errors)>0){
foreach($errors as $k=>$v){
echo '<br/>'.$v;
}
}?></th>
</tr>
<tr>
<td>Captcha</td>
<td>
<!-- image inserted from php_captcha.php -->
<input type="image" name="imageField" src="php_captcha.php" /></td>
</tr>
<tr>
<td> </td>
<td>
<!-- user input where the captcha value is set -->
<input name="captchacode" type="text" id="captchacode" /></td>
</tr>
</table>
<button onclick="javascript:if (confirm('Etes-vous sûre de vouloir supprimer cet utilisateur ?')) document.forms['myform'].submit(); else return false ;">Supprimer</button>
</td>
</fieldset>
</form>