Hallo
in diesen Tutorial will ich euch zeigen wie man ganz einfach mit PHP ein Captcha Code System coded.
Wir nennen die erste Datei mal "Captcha.php". Gebe Folgenden Code da ein:
Die nächste Datei nennen wir mal "form.php" mit folgenden Code:
So nun nur noch auf eurem Webserver hochladen.
Test: Klick
Download: Klick
Danke
in diesen Tutorial will ich euch zeigen wie man ganz einfach mit PHP ein Captcha Code System coded.
Wir nennen die erste Datei mal "Captcha.php". Gebe Folgenden Code da ein:
PHP-Quellcode
- <?php
- session_start();
- $breite = 150;
- $hoehe = 50;
- $counter_l = 10;
- $counter_w = 7;
- $sec_word = "";
- for($w=0;$counter_w>$w;$w++)
- {
- $letter = rand(97,122);
- $sec_word .= chr($letter);
- }
- header('Content-Type: image/png');
- $img = imagecreate($breite,$hoehe);
- $background = imagecolorallocate($img, rand(200,255),rand(200,255),rand(299,255));
- for ($l=0;$counter_l>$l;$l++)
- {
- $color_l = imagecolorallocate($img,rand(150,200),rand(150,200),rand(150,200));
- imagedashedline($img,0,rand(0,50),150,rand(0,50),$color_l);
- }
- for($i=0;$counter_w>$i;$i++)
- {
- $size = "5";
- $x = $i*15+15;
- $color_w = imagecolorallocate($img,rand(0,100),rand(0,100),rand(0,100));
- imagestring($img,$size,$x,10,$sec_word[$i],$color_w);
- }
- imagepng($img);
- imagedestroy($img);
- $_SESSION['sec_word'] = $sec_word;
- ?>
Die nächste Datei nennen wir mal "form.php" mit folgenden Code:
PHP-Quellcode
- <?php
- session_start();
- if($_POST['sub'])
- {
- if($_POST['captcha'] == $_SESSION['sec_word'])
- {
- echo "Richtig!!!";
- }else{
- echo "Falsch ;(";
- }
- }
- ?>
- <form action=form.php method=POST>
- <input type="text" name="captcha" /> <br />
- <img src="captcha.php" /><br />
- <input type="submit" name="sub" value"Test" />
- </form>
So nun nur noch auf eurem Webserver hochladen.
Test: Klick
Download: Klick
Danke
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „GirlOnFire“ ()