Create a verification code, suddenly a lot of errors, please help to see, thank you
I'm trying to write a PHP script with a verification code, I start by suggesting that the image function is not available, so I added the PHP5-GD
After the installation is complete, the discovery or the tip cannot find the function
So I used Sudo/etc/init.d/apache2 focus-reload.
Then prompts for a function problem, but displays a large number of warning messages
I viewed the Modify php.ini file Error.report =e_all & ~e_notice
Restart the server but still,
The code is generated as follows
Session_Start ();
Set some important Identfy constants
Define (' Identfy_num ', 5);
Define (' Identfy_width ', 75);
Define (' Identfy_heigt ', 25);
Create the Random Pass-phrase
$pass _phrase= "";
for ($i =0; $i
<>
$pass _PHRASE.=CHR (rand (97,122));
}
$_session[' Pass_phrase ']=sha1 ($pass _phrase);
$img =imagecreatetruecolor (identfy_width,identfy_height);
$BG _color=imagecolorallocate ($img, 255,255,255);
$text _color=imagecolorallocate ($img, 0,0,0);
$graphic _color=imagecolorallocate ($img, 64,64,64);
Imagefilledrectangle ($img, 0,0,identfy_width,identfy_height, $BG _color);
Draw Random Lines
for ($i =0; $i <5; $i + +) {
Imageline ($img, 0,rand ()%identfy_height,identfy_width,rand ()%indentfy_height, $graphic _color);
}
for ($i =0; $i <50; $i + +) {
Imagesetpixel ($img, Rand ()%identfy_width,rand ()%identfy_height, $graphic _color);
}
Draw the string
Imagettftext ($img, 18,0,5,identfy-5, $text _color, "Courier New Bold.ttf", $pass _phrase);
Header ("Content-type:image/png");
Imagepng ($IMG);
Imagedestroy ($IMG);
?>
------Solution--------------------
Check yourself, the definition and use of constants are inconsistent
------Solution--------------------
It's obvious that 23 lines of your division inside the denominator cannot be zero because there are errors upside down $img variables have miscellaneous values so that 27 rows of imagesetpixel function do not have a usable picture resource
for ($i =0; $i <5; $i + +) {
Imageline ($img, 0,rand ()%identfy_height, Identfy_width,rand ()%indentfy_height, $graphic _color);
}
for ($i =0; $i <50; $i + +) {
Imagesetpixel ($img, Rand ()%identfy_width,rand ()%identfy_height, $graphic _color);
}