Jump to content

[SOLVED] problem with image, code verification, form


yami007

Recommended Posts

i created 2 independent files : png.php & recaptcha.php

this is what i wrote on recaptcha.php

<?php
session_start();
$chaine = 'abcdefghijklmnopqrstuvwxyz123456789';
$chaine = str_shuffle($chaine);
$chaine = substr($chaine, -6);
$_SESSION['code'] = $chaine;
?>

 

and this is png.php

<?php
header("Content-type: image/png");
$im = imagecreate(60,20);
$blue 	= imagecolorallocate($im,0,0,0);
$white 	= imagecolorallocate($im,255,255,255);
$black 	= imagecolorallocate($im,0,0,0);
require_once("recaptcha.php");
$text = $_SESSION['code'];
imagestring($im, 3, 8, 2, $text, $white);

imagepng($im);
?>

 

and then i called the png.php file as the verification code image

<td valign="middle"><img src="../includes/png.php" /> ==> 
<input dir="ltr" type="text" name="code" value="" size="30"/><br/>
<input dir="ltr" type="hidden" name="code2" value="<?php echo $_SESSION['code']; ?>" size="30"/>
<?php echo $_SESSION['code']; ?>

but i have this problem :

i am calling the same variable but the image, hidden input and the last echoed variable show different things and when i check the source , i find that they are all alike, what is the problem???

in png.php you need to call session_start, if you did I did not see it in the code you posted. You will also need to do that on the place where you post the re-captcha check.

 

Verify those, if they are already done then write back and I will dig a little deeper.

in png.php you need to call session_start, if you did I did not see it in the code you posted. You will also need to do that on the place where you post the re-captcha check.

 

Verify those, if they are already done then write back and I will dig a little deeper.

OK, i done what u said but still the same issue!!

I'll tell u what happens exactly;

when i open the page first time, the image shows : ubg5rp, and the hidden input shows : x6qk51.

when i reload it, the image shows new code and the hidden input shows : ubg5rp

I dont know what to do here...

solved, here is what i done :

i moved the recaptcha.php to add-word.php which is my form process file:

<?php 
session_start();
$chaine = 'abcdefghijklmnopqrstuvwxyz123456789';
$chaine = str_shuffle($chaine);
$chaine = substr($chaine, -6);
$_SESSION['code'] = $chaine;
?>

and removed the file and call the session in both files, png.php and add-word.php

and now the results are the same :)

thanks ^^

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.