Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
验证(或sesame)的主要PHP方法$\u POST submit_Php_Forms - Fatal编程技术网

验证(或sesame)的主要PHP方法$\u POST submit

验证(或sesame)的主要PHP方法$\u POST submit,php,forms,Php,Forms,我想添加sesame并在用户进入操作页面时验证它示例: if(isset($_POST["contact-us"])) { //some code }elseif(isset($_POST["site-feedback"])) { //some code }else{get_error('form');} 我目前的想法是为contact-us.php添加$\u SESSION[“SESAMEOPEN”][“contact-us”]=“uniquesalt”,然后将表单发送到操作页面进行验证 我

我想添加sesame并在用户进入操作页面时验证它示例:

if(isset($_POST["contact-us"])) {
//some code
}elseif(isset($_POST["site-feedback"])) {
//some code
}else{get_error('form');}
我目前的想法是为contact-us.php添加
$\u SESSION[“SESAMEOPEN”][“contact-us”]=“uniquesalt”
,然后将表单发送到操作页面进行验证

我面临的问题是:例如,用户在访问contact-us.php时打开另一个页面,用户仍然可以通过操纵
输入type=“submit”name=“contact-us”
来访问操作页面。而检查重定向页面的方法似乎也能被欺骗


验证操作页面的主流方式是什么?我想要的是,用户只能从特定的form.php访问action.php。

您尝试过salt散列令牌吗?它们对时间很敏感。CSRF备忘单似乎非常有用,我将花一些时间研究它的工作机制。我认为您应该在$\u会话变量中管理带有时间的令牌列表。如果用户打开联系人页面,则应将新令牌添加到该列表中。在提交联系人表单时,将收到的令牌与时间匹配(比如10分钟)。如果匹配,则接受联系人表单,否则拒绝并使用新令牌(添加到会话中)再次显示联系人表单。您还可以从已过期的令牌列表中删除令牌(例如10分钟)。