POST[]ing Extra Values

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 04:59:18

问题


I am creating a custom captcha where random numbers are generated and you have to add them together etc. As of right now I am echo-ing these random numbers but now I need to pull them into a external file to test the sum against the input text. Can I add these to the POST[] array on form submission?


回答1:


You have to have some way of keeping track of the numbers and retrieving them back later for verification. You could use session variables- put the numbers in at the time of the page load, and then again when the form is POST'd and check them against each other.

Also, keep in mind anything on the form or that is put in $_POST can be easily viewed by anyone attempting to fool this process. Putting them in session variables makes it much harder for someone to view the contents of what their numbers will be checked against.




回答2:


Shouldn't be necessary to post the numbers back. Just store them in a session variable on the server (or even just store the desired answer) and compare that. There'd be no point in storing the individual numbers, since they'd be thrown away and new ones generated each time anyways - captcha images/tests should never be reused.



来源:https://stackoverflow.com/questions/6835151/posting-extra-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!