yami007 Posted November 20, 2009 Share Posted November 20, 2009 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??? Link to comment https://forums.phpfreaks.com/topic/182232-solved-problem-with-image-code-verification-form/ Share on other sites More sharing options...
premiso Posted November 20, 2009 Share Posted November 20, 2009 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. Link to comment https://forums.phpfreaks.com/topic/182232-solved-problem-with-image-code-verification-form/#findComment-961626 Share on other sites More sharing options...
yami007 Posted November 20, 2009 Author Share Posted November 20, 2009 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... Link to comment https://forums.phpfreaks.com/topic/182232-solved-problem-with-image-code-verification-form/#findComment-961832 Share on other sites More sharing options...
yami007 Posted November 20, 2009 Author Share Posted November 20, 2009 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 ^^ Link to comment https://forums.phpfreaks.com/topic/182232-solved-problem-with-image-code-verification-form/#findComment-961838 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.