?看評論區說沒加session_start();但是在php文件中加了session_start()還是出現錯誤<?php?? ?session_start();//1.創建畫布? ?$image = imagecreatetruecolor(100, 30);//創建一個高100寬30的畫布(默認背景是黑色)? ?$bgcolor = imagecolorallocate($image, 255, 255, 255);//#fff ?imagecolorallocate為圖像分配顏色? ?imagefill($image, 0, 0, $bgcolor);//區域填充?? ?// 2.實現數字加字母驗證碼(二)? ?$captch_code = '';? ?for($i=0;$i<4;$i++){? ? ?$fontsize = 6;? ? ?$fontcolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));? ? ?$data = '123456789';? ? ?$fontcontent = substr($data, rand(0,strlen($data)-1),1);? ? ?$captch_code.=$fontcontent;? ? ?$x = ($i*100/4) + rand(5,10);? ? ?$y = rand(5,10);? ? ?imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);? ?}? ?$_SEESSION['authcode']=$captch_code;//3.增加干擾元素? ?//增加點干擾? ?for ($i=0; $i < 200; $i++) {?? ? ?$pointcolor = imagecolorallocate($image, rand(50,200), rand(50,200), rand(50,200));? ? ?imagesetpixel($image, rand(1,99), rand(1,29), $pointcolor);? ?}? ?//增加線干擾? ?for ($i=0; $i < 3; $i++) {?? ? ?$linecolor = imagecolorallocate($image, rand(80,220), rand(80,220), rand(80,220));? ? ?imageline($image, rand(1,99), rand(1,29), rand(1,99), rand(1,29), $linecolor);? ?}? ?header('content-type:image/png');//向瀏覽器輸出圖片頭信息? ?imagepng($image);//輸出圖片到瀏覽器? ?//end? ?imagedestroy($image);//銷毀圖片
Notice: Undefined index: authcode in E:\xampp\htdocs\project\form.php on line 5 輸入錯誤
慕粉1939118473
2017-09-01 12:20:49