Posted by ptdorf on 09/16/07 14:30
> 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');
?>
[Back to original message]
|