php Image CAPTCHA

0 Cevap

Aşağıda programın kaynak kodu. Herkes bana bir programın çalışma anlamaya yardımcı olabilir.

<?php
session_start();
?>
<?php
  $aCaptcha = array (
        array(),
        array('crocodile'),
        array('panda', 'panda bear', 'giant panda'),
        array('pig'),
        array('tiger'),
        array('zebra'),
        array('cow'),
        array('elephant')
    );

if (isset($_POST['register'])) {
    $error = array();
        if (!in_array(strtolower($_POST['captcha']), $aCaptcha[$_SESSION['captcha']])) {
        $error['captcha'] = "<span style='color:red'>The name of the animal is not correct.</span>";
    }
    if (count($error) == 0) {
                    echo "<span style='color:red'>Thank you for completing the form.
We shall contact you soon.</span>";
        die();
    }
}
?>
<form action="index.php" method="post">
    <?php
            $_SESSION['captcha'] = rand(1, 7);
    ?>  
<td colspan="3"><strong>Contact Form</strong></td>

             <p>Full Name :                   <input type="text" name="Nmaes" value='' />
<p>Mobile No. :                   <input type="text" name="Nmaes" value='' />
             <p>Email id :                   <input type="text" name="Nmaes" value='' />
             <p>Subject :                   <input type="text" name="Nmaes" value='' />
 <p>Message :                   <input type="text" name="Nmaes" value='' />
    <p><img src="<?php echo $path;?>captcha/<?php echo $_SESSION['captcha'];?>.jpg" /></p>
    <p>Type the name of the animal you see in the picture above. <input type="text" name="captcha" value='' />
    <?php echo(isset($error['captcha']))?$error['captcha']:"";?></p>
    <p><label>&nbsp;</label><input type='submit' name='register' value='register' /></p>
</form>

0 Cevap