Jump to content
php.lv forumi

captcha


chizijs

Recommended Posts

<?php
session_start();
error_reporting(E_ALL);
?>
<form action="" method="post">
E-pasts: <input name='email' type='text'><br/>
<?php
$r1 = rand(0,9);
$string = $r1*10+rand(3,5)*3;
$_SESSION['captcha'] = $string;
$font_size = 5;
$width=imagefontwidth($font_size)*strlen($string);
$height=imagefontheight($font_size)*2;
$img = imagecreate($width,$height);
$bg = imagecolorallocate($img,255,255,255);
$black = imagecolorallocate($img,0,0,0);
$len=strlen($string);
for($i=0;$i<$len;$i++)
{
   $xpos=$i*imagefontwidth($font_size);
   $ypos=rand(0,imagefontheight($font_size));
   imagechar($img,$font_size,$xpos,$ypos,$string,$black);
   $string = substr($string,1);   
header("Content-Type: image/gif");
imagegif($img);
imagedestroy($img);
}
?>
<input name='db' type='text'><br/>
<input name='submit' type='submit' value='Nosūtīt'>
</form>

Bet errori parādās

Warning: Cannot modify header information - headers already sent by (output started at C:\webserv\xampp\htdocs\lockerz.php:7) in C:\webserv\xampp\htdocs\lockerz.php on line 37

GIF87a$€ÿÿÿ,$3„©Ëí£œ´Ú‹³Þ¼û†âH–æ¤Á˜-øºëu÷ª¢~‡ý6“ùf?Ž*xJ*?;

Warning: imagechar(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 35

 

Warning: Cannot modify header information - headers already sent by (output started at C:\webserv\xampp\htdocs\lockerz.php:7) in C:\webserv\xampp\htdocs\lockerz.php on line 37

 

Warning: imagegif(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 38

 

Warning: imagedestroy(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 39

 

Warning: imagechar(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 35

 

Warning: Cannot modify header information - headers already sent by (output started at C:\webserv\xampp\htdocs\lockerz.php:7) in C:\webserv\xampp\htdocs\lockerz.php on line 37

 

Warning: imagegif(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 38

 

Warning: imagedestroy(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 39

 

Warning: imagechar(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 35

 

Warning: Cannot modify header information - headers already sent by (output started at C:\webserv\xampp\htdocs\lockerz.php:7) in C:\webserv\xampp\htdocs\lockerz.php on line 37

 

Warning: imagegif(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 38

 

Warning: imagedestroy(): 2 is not a valid Image resource in C:\webserv\xampp\htdocs\lockerz.php on line 39

Edited by chizijs
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...