Reply to Re: a silly question on sessions

Your name:

Reply:


Posted by Ian Hobson on 04/17/07 22:53

Swann wrote:
> 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? :)
>
You are generating the passcheck in the captcha.php. The request for
this image occurs after the form has been recieved by the browser.
This is after the form has been generated on the server, when it will
contain the old value.

It is the script that handles the post from the form has to get
passcheck from the session variable and the field from the user and
check they are identical. For testing, this script could report what it
actually found in both.

Regards

Ian

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация