jmr3460 Posted July 19, 2009 Share Posted July 19, 2009 I am trying to invoke a class. I have inserted the code into a simple form as was directed by the README file I am getting this Fatal Error message: Fatal error: Class 'captcha' not found in /home3/simplic5/public_html/php/captcha/captcha/index.php on line 10 This is my form: <?php ob_start(); session_start(); ?> <form method="post" action="captcha.php"> <table border="0" cellspacing="3" cellpadding="3"> <tr><td align="right"><input type="text" name="image"></td></tr> <tr><td align="right"> <?php echo captcha::form(); ?></td></tr> <tr><td align="right"><input type="submit" name="submit" value="Check CAPTCHA\"></td></tr> </table></form> Is the class invoked like an include (I have tried putting the folder my includes folder)? What defines this as a class? Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/ Share on other sites More sharing options...
Daniel0 Posted July 19, 2009 Share Posted July 19, 2009 You must include or require the file that contains the captcha class. Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878062 Share on other sites More sharing options...
jmr3460 Posted July 19, 2009 Author Share Posted July 19, 2009 OK I got a different error now. The error is actually an image itself. It says: The image "http://www.mysite.com/captcha/" can not be displayed because it contains errors. If I run the script by itself it works great. I got this script from a video tutorial that I found doing a search. Here is the script: <?php session_start(); $img = imagecreatetruecolor(80,30); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $grey = imagecolorallocate($img,150,150,150); $red = imagecolorallocate($img, 255, 0, 0); $pink = imagecolorallocate($img, 200, 0, 150); function randomString($length){ $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $str = ""; $i = 0; while($i <= $length){ $num = rand() % 33; $tmp = substr($chars, $num, 1); $str = $str . $tmp; $i++; } return $str; } for($i=1;$i<=rand(1,5);$i++){ $color = (rand(1,2) == 1) ? $pink : $red; imageline($img,rand(5,70),rand(5,20), rand(5,70)+5,rand(5,20)+5, $color); } imagefill($img, 0, 0, $white); $string = randomString(rand(7,10)); $_SESSION['string'] = $string; imagettftext($img, 11, 0, 10, 20, $black, "calibri.ttf", $string); header("Content-type: image/png"); imagepng($img); imagedestroy($img); ?> Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878082 Share on other sites More sharing options...
Daniel0 Posted July 19, 2009 Share Posted July 19, 2009 Ok so what you'll want to do is to place an image like this: <img src="path/to/captcha.php"> Where the src is the path to the script that generates a CAPTCHA image of course. Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878084 Share on other sites More sharing options...
jmr3460 Posted July 19, 2009 Author Share Posted July 19, 2009 OK Thank you very much. Now I need to find out how to have the form check the value of the image verses the value of the input field. I have pointed the action of the form to the file in the includes folder. I will see how that works. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878091 Share on other sites More sharing options...
Daniel0 Posted July 19, 2009 Share Posted July 19, 2009 Well, as you see, in the CAPTCHA script you stored $_SESSION['string'] = $string;, so you can simply match that value with the one the user entered when you are processing the form input. Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878096 Share on other sites More sharing options...
jmr3460 Posted July 19, 2009 Author Share Posted July 19, 2009 Thanks for the info. I will have to work on this later. I have an appointment I have to make. I am going to consider this topic solved. Thanks again for the replies. Quote Link to comment https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/#findComment-878108 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.