|
Posted by Vince Morgan on 04/18/07 01:04
"Swann" <nomailatall9182374614@hotmail.com> wrote in message
news:f02ctg$7sd$1@tdi.cu.mi.it...
>
> i'm trying to write a very simple CAPTCHA script. following some examples
> and working a bit on the code to suit my needs, i managed to generate the
> random image as desired. i have a php file with the form to be filled
> (called "form.php"), and another one with the code needed to generate the
> CAPTCHA image (called "captcha.php"). int the former i have a simple IMG
tag
> in the former file to call the latter, like this:
>
> <img src="captcha.php">
>
>
> before writing the code needed to process the entered password against the
> value of the one displayed in the image, i wanted to make sure that the
> script was getting the correct value. "captcha.php", after randomly
> generating the password, puts its value into a session var using the
> following instruction:
>
> $_SESSION["passcheck"] = $pass;
>
> i put the following line at the end of "form.php", to check if the value
was
> passed correctly:
>
>
> print "VAR VALUE: ".$_SESSION["passcheck"];
>
> here comes the problem: the script always displays the *former* value of
the
> variable, not the current one. for example, if the first time i run the
> script the image displays, say, "AAAAA", the bottom line displays "VAR
> VALUE: " with an empty string after it.
> i have to reload the page to see "VAR VALUE: AAAAA", but of course in the
> meantime the image has changed to, say "BBBBB". i am sure it's a very
silly
> thing, but right now i just can't manage to untie the knot. anybody wants
to
> point out how stupid i am by giving me some advice? :)
>
> thanks a lot.
>
> swann
>
>
I'll see if if I can demonstate how stupid I can be by attempting to answer
your question ;)
After you generate your password try the following;
$_SESSION["passcheck"] = $pass;
$GLOBALS["passcheck"]=&$_SESSION["passcheck"];
HTH
Vince
Navigation:
[Reply to this message]
|