PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > how to verify the code?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
how to verify the code?

Réponse
 
LinkBack Outils de la discussion
Vieux 16/09/2007, 12h52   #1 (permalink)
nightcats@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to verify the code?

Hi,

I try to put a very basic Capcha system in my forum. I've already
figure out how to randonly generate a combination:

<?
function Pass($i=8) {
srand((double)microtime()*1000000);
return strtoupper(substr(md5(uniqid(rand())),rand(0,32-$i),
$i));
}
echo Pass(4)."<br>";
echo;
?>

======

But I don't know how to generate an text area for my visitors to input
the code, and verify the value with the combination.

Can anyone me to finish the rest of the verification process?
Thanks thanks thanks thanks a million.

  Réponse avec citation
Vieux 16/09/2007, 14h31   #2 (permalink)
ptdorf@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to verify the code?

> But I don't know how to generate an text area for my visitors to input
> the code, and verify the value with the combination.
>
> Can anyone me to finish the rest of the verification process?
> Thanks thanks thanks thanks a million.


You need an image to generate the Captcha random letters, store that
generated string in the $_SESSION super globals ($_SESSION['Captcha']
or something like this) and then, check the input from the form
against the $_SESSION.

The image with the random captcha text can be created with php built-
in function to manip images. Then on your form, you just need to add
the captcha image something like: <img src="captcha.php" /> and that
captcha.php file should generate the image and set the text in the
session.

At least, thats my way...

  Réponse avec citation
Vieux 16/09/2007, 14h59   #3 (permalink)
nightcats@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to verify the code?

On 9 16 , 9 31 , ptd...@gmail.com wrote:
> > But I don't know how to generate an text area for my visitors to input
> > the code, and verify the value with the combination.

>
> > Can anyone me to finish the rest of the verification process?
> > Thanks thanks thanks thanks a million.

>
> You need an image to generate the Captcha random letters, store that
> generated string in the $_SESSION super globals ($_SESSION['Captcha']
> or something like this) and then, check the input from the form
> against the $_SESSION.
>
> The image with the random captcha text can be created with php built-
> in function to manip images. Then on your form, you just need to add
> the captcha image something like: <img src="captcha.php" /> and that
> captcha.php file should generate the image and set the text in the
> session.
>
> At least, thats my way...


thanks for replying.

well......I really don't need to go that far. I think for now a random
text is enough.

Now I can make my webpage generates a random combination. All I need
next is to creat a text area to compare with the randon code
generated, as what I said in my first article.

Can anybody me with the rest part of the verifying process?
thanks.


  Réponse avec citation
Vieux 16/09/2007, 15h30   #4 (permalink)
ptdorf@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to verify the code?

> Now I can make my webpage generates a random combination. All I need
> next is to creat a text area to compare with the randon code
> generated, as what I said in my first article.


something like this:

<!-- create the form -->

<form method="POST">
Please, write down the following code: <?php
$code = Pass(4);
$_SESSION['Captcha'] = $code;
echo $code; ?>
<input type="text" name="code" />
<input type="submit" />
</form>

<!-- check the code -->
<?php

$valid = 0;
if (isset($_POST['code'])) {
if (isset($_SESSION['code'])) {
$valid = $_POST['code'] == $_SESSION['code'];
}
}
echo 'The code is ', ($valid ? 'valid' : 'invalid');
?>

  Réponse avec citation
Vieux 16/09/2007, 15h32   #5 (permalink)
ptdorf@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to verify the code?

Sorry, not:
> $_SESSION['Captcha'] = $code;



But:
> $_SESSION['code'] = $code;


  Réponse avec citation
Vieux 16/09/2007, 17h06   #6 (permalink)
nightcats@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to verify the code?

On 9 16 , 10 32 , ptd...@gmail.com wrote:
> Sorry, not:
>
> > $_SESSION['Captcha'] = $code;

>
> But:
>
>
>
> > $_SESSION['code'] = $code;- -

>
> - -


Hi

I just want to say "thank you".

with your , I made a little adustment myself. I've got it all
figured out.

Thanks again.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h12.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,86936 seconds with 14 queries