hi mache mir grade ein captcha
captcha.php
Alles anzeigen
Testdatei.php
so das problem ist wenn ich denn cookie auslese dann bekomme ich immer die kombination die als vorletztes generiert wurde
captcha.php
Quellcode
- <?php
- $template = "1234567890abcdefghijklmnopqrstuvwxyz";
- function GetRandomString($length) {
- global $template;
- settype($length, "integer");
- settype($rndstring, "string");
- settype($a, "integer");
- settype($b, "integer");
- for ($a = 0; $a <= $length; $a++) {
- $b = rand(0, strlen($template) - 1);
- $rndstring .= $template[$b];
- }
- return $rndstring;
- }
- $id = GetRandomString(7);
- setcookie("captcha", $id);
- $text = $id;
- $grafik = "images/captcha.jpg";
- $font = "images/actionj.ttf";
- $img = imageCreateFromJPEG($grafik);
- $farbe = imageColorAllocate($img, 0, 0, 0);
- ImageTTFText($img, 35, 8, 16, 75, $farbe, $font, $text);
- header("Content-type: image/JPEG");
- imageJPEG($img);
- imageDestroy($img);
- ?>
Testdatei.php
so das problem ist wenn ich denn cookie auslese dann bekomme ich immer die kombination die als vorletztes generiert wurde