html - Apache "localhost is currently unable to handle this request." php request -
i'm using apache 2.4 server on laptop running under windows 10. i’m having problem running piece of php code supposed show random numbers users tap in, know user not robot. below picture shows i’m talking about: the numbers have yellow background i'm referring.
so, code have generating these number follows:
<?php /** usage: <img alt="" rel="nofollow,noindex" width="50" height="18" src="php/captcha.php" /> $_session['captcha'] - use in script. supported link: util/captcha.php?w=100&h=50&s=30&bgcolor=ffffff&txtcolor=000000 **/ session_start(); @ini_set('display_errors', 0); @ini_set('track_errors', 0); header('cache-control: no-cache'); header('pragma: no-cache'); /** ********************************** @random generators [ln, n, l] /** ******************************* **/ function random($length=6,$type=null) { // null = letters+numbers, l = letters, n = numbers switch($type) { case 'n' : $chars = '0123456789'; break; case 'l' : $chars = 'abcdefghijklmnopqrstuvwxyz'; break; default : $chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; break; } $numchars = strlen($chars); $string = ''; ($i = 0; $i < $length; $i++) { $string .= substr($chars, rand(1, $numchars) - 1, 1); } unset($chars); return $string; } /** ********************************** @_get shortcut , protect /** ******************************* **/ function _getvar($var) { if(isset($_get[$var])) { return trim($_get[$var]); } else { return null; } } /** ********************************** @captcha /** ******************************* **/ // put code in session use in script if(_getvar('c') != '') $c = (int) _getvar('c'); else $c = 6; $mycode = random($c,'n'); $_session['captcha'] = $mycode; // image size specified dimensions $w = (int) _getvar('w'); if($w == '') $w = 60; // width $h = (int) _getvar('h'); if($h == '') $h = 18; // height $s = (int) _getvar('s'); if($s == '') $s = 5; // font size [5 max.] $bgcolor = _getvar('bgcolor'); if($bgcolor == '') $bgcolor = 'ffffff'; // background color [ffffff default] $txtcolor = _getvar('txtcolor'); if($txtcolor == '') $txtcolor = '000000'; // text color [000000 default] // convert color r g b // [from ffffff ff ff ff] $bgcol = sscanf($bgcolor, '%2x%2x%2x'); $txtcol = sscanf($txtcolor, '%2x%2x%2x'); // create image $code = $_session['captcha']; $image = imagecreate($w, $h); // image size [50x18 default] $bgcol = imagecolorallocate($image, $bgcol[0], $bgcol[1], $bgcol[2]); // background color $txcol = imagecolorallocate($image, $txtcol[0], $txtcol[1], $txtcol[2]); // text color $strn2 = imagestring($image, $s, 0, 0, $code, $txcol); // text size [4 default] header('content-type: image/jpeg'); // imagepng($image); // make sure --with-png-dir set imagejpeg($image); imagedestroy($image); ?>
when run code on apache,
"the localhost page isn’t working. localhost unable handle request. http error 500"
this error. i'm aware server error runs ok using mac ox operating system has apache pre-installed. code above error on if use windows 10 have apache , php installed instructed on youtube.
can help?? in advance!
that telling apache cant find native error page 500. have error in php code, change display_errors
1 , add next error_reporting(-1);
Comments
Post a Comment