我有一个 PHP 中的用户注册表单。我在页面中放入了验证码图像检查。我像这样使用它
//img id="imgCaptcha" src="create_image.php"//
在我的 javascript 中我想用它来验证它与图像中生成的数字相同(来自 create_image.php 页面)。 该数字也在会话变量中设置。 但是当我从 SESSION 获取数字时,我得到了上一个生成的数字。但是当我发布该页面时,我得到了由 SESSION 的 create_image.php 生成的正确数字。
那么,如何在不从 SESSION 发布该页面的情况下获取最近生成的号码?
I have a user registration form in PHP .I put captcha image check in the page.I used it like this
//img id="imgCaptcha" src="create_image.php"//
and in my javascript i want to validate this with the same number which is generated in the image (from create_image.php page) . That number was set in a session variable too. but when I get number from SESSION that time I get previous one generated number.but when I POST that page I get correct one generated by create_image.php from SESSION.
so,how can I get recently generated number without posting that page from SESSION?
发布评论
评论(1)
问题在于,带有图像的 php 页面是在代码发布到客户端后加载的,因此当您尝试从会话中输出数字时,您会得到您所描述的结果。
在我看来,有树形解决方案:
The problem is that the php-page with the image is loaded after the code is posted to the client, so when you try to output the number from the session, you get the result you describe.
As i see it, there are tree solutions: