Jump to content

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


sayedsohail

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

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.