Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 144541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:16:11+00:00 2026-05-11T08:16:11+00:00

I’m trying to develop a captcha class for my website everything was doing fine

  • 0

I’m trying to develop a captcha class for my website everything was doing fine until I tried to embed the image generated with PHP GD inside my subscription form!

Here is the code of my class:

<?php //captcha.php header('Content-type: image/png');   class Captcha  {     // some attributes bla bla    public function __construct($new_string_length,$new_width_picture,                               $new_height_picture,$new_string_color) {      $this->string_length = $new_string_length;     $this->width_picture = $new_width_picture;     $this->height_picture = $new_height_picture;     $this->string_color = $new_string_color;    }    public function getString() {     return $this->string;   }    public function generateRandomString() {     $str = '';     $basket = 'abcdefghijklmnopqrstuvwxyz0123456789';     $basket_length = strlen($basket);     srand ((double) microtime() * 1000000);     for($i=0;$i<$this->string_length;$i++) {          $generated_pos = rand(0,$basket_length);         $str_substr = substr($basket,$generated_pos-1,1);         if(!is_numeric($str_substr)) {            // if the character picked up isn't numeric           if(rand(0,1)==1) {             // we randomly upper the character             $str_substr = strtoupper($str_substr);           }         }         $str = $str.$str_substr;     }      $this->string = $str;   }     **public function generatePictureFromString($new_string) {       $root_fonts = '../fonts/';       srand ((double) microtime() * 1000000);       $list_fonts = array('ABODE.ttf','acme.ttf','Alcohole.ttf',                    'Anarchistica.ttf','AMERIKAA.ttf');        $image = @imagecreatetruecolor($this->width_picture,$this->height_picture);       $noir  = imagecolorallocate($image,0,0,0);       $clr = explode('/',$this->string_color);       $clr = imagecolorallocate($image,$clr[0],$clr[1],$clr[2]);           for($i=0;$i<strlen($new_string);$i++) {                   imagettftext($image,rand(($this->height_picture/4.3),($this->height_picture)/4.2),            rand(-45,45),($this->width_picture)/(5*$this->string_length)+($this->width_picture)/($this->string_length)*$i,0.6*($this->height_picture),$clr,            $root_fonts.$list_fonts[rand(0,count($list_fonts)-1)],substr($new_string,$i,1));       }        imagepng($image);       imagedestroy($image);    }**  } 

I willingly avoided to show some useless part of the class. The class itself works perfectly when I call the generatePictureFromString(..) method like this:

<?php //testeur_classe.php require_once '../classes/captcha.php';  $captcha = new Captcha(5,200,80,'255/255/255'); $captcha->generateRandomString(); $str  = $captcha->getString(); $captcha->generatePictureFromString($str);  ?> 

But when I try to insert the picture generated in my form using:

<img src='<?php echo PATH_ROOT.'classes\testeur_classe.php'; ?>'/> 

nothing is displayed!

How am I supposed to do that ?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:16:12+00:00Added an answer on May 11, 2026 at 8:16 am

    You need to make sure that the image src is a valid URL to the script. Looking at the backslash in there my guess would be that that is in fact a filesystem path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 209k
  • Answers 209k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's using the FancyZoom plugin, pretty sure cabel.name was the… May 12, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer Did not verify but you might want to use the… May 12, 2026 at 9:46 pm
  • Editorial Team
    Editorial Team added an answer Got it working using this. This was the problem: In… May 12, 2026 at 9:46 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.