Jump to content

[SOLVED] migrated from xampp? captcha file stop showing image?


Recommended Posts

Removed xampp and installed php apache mysql?

Hi guys,

 

When i migrated from xampp, i got a small problem, when uninstalled xampp and installed apache, php and mysql separately.

 

My captach file is not showing up the image on my login page.

 

login.php file

<?php
....////Just avoided loading entire form///
<input id="txtCaptcha" type="text" name="txtCaptcha" value="" maxlength="10" size="32" />
    </td>
    <td>
      <img id="imgCaptcha" src="create_image.php" />
    </td>

?>
.......

 

captch file:

[/code]

<?php

session_start();

 

//Send a generated image to the browser

create_image();

exit();

 

function create_image()

{

   

    $md5_hash = md5(rand(0,999));

    $security_code = substr($md5_hash, 15, 5);

    $_SESSION["security_code"] = $security_code;

    $width = 100;

    $height = 20;

    $image = ImageCreate($width, $height); 

    $white = ImageColorAllocate($image, 255, 255, 255);

    $black = ImageColorAllocate($image, 0, 0, 0);

    $grey = ImageColorAllocate($image, 204, 204, 204);

    ImageFill($image, 0, 0, $black);

    ImageString($image, 3, 30, 3, $security_code, $white);

    ImageRectangle($image,0,0,$width-1,$height-1,$grey);

    imageline($image, 0, $height/2, $width, $height/2, $grey);

    imageline($image, $width/2, 0, $width/2, $height, $grey);

//It seems i got problem, somewhere here to do with header, i am not good at understanding headers at all//

    header("Content-Type: image/jpeg");

 

    ImageJpeg($image);

 

    //Free up resources

    ImageDestroy($image);

}

?>

[/code]

I was able to solve on my own, as i hate using xampp, in live environment, instructions are on this website. and make sure you copied php g2.dll file inside the php ext directory.  if someone needs feel free to pm.

 

regards,

sohail

 

http://www.webcheatsheet.com/php/install_and_configure.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.