Jump to content

[SOLVED] Help with invoking class


jmr3460

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/166510-solved-help-with-invoking-class/
Share on other sites

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);
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.