简体   繁体   English

我如何保持php表单过程脚本不被单独处理,而不从其html页面调用?

[英]How can I keep a php form process script from being processed alone, without being called from its html page?

I've been ask to troubleshoot a problem on a very, very old html website which I did not build. 我一直被要求对一个我没有建立的非常老的html网站进行故障排除。 There are two html forms which each call their own php scripts to process them. 有两种HTML表单,每个表单都调用自己的php脚本来处理它们。 They have been getting empty form submissions. 他们一直在提交空白表格。 I put code in place to make three of the fields mandatory as well as added a captcha form. 我将代码放置到位,以使三个字段成为必填字段,并添加了一个验证码表单。 When you go through the normal process, these measures work to stop empty form submissions. 当您执行正常过程时,这些措施可以停止提交空白表格。 However, they are still getting empty form submissions. 但是,他们仍在提交空白表单。 I discovered that if you enter the script url directly in a browser, for example form-process.php, it does submit the empty form without the mandatory fields nor the captcha. 我发现,如果您直接在浏览器中输入脚本URL,例如form-process.php,它将提交没有必需字段或验证码的空表单。

Any suggestions on keeping this script from running on it's own? 关于阻止此脚本自己运行的任何建议?

Thank you in advance. 先感谢您。 PS, I am a php novice, so the php for dummies version would be appreciated. PS,我是一名PHP新手,因此适用于傻瓜版本的PHP将不胜感激。

You can do two things (either or and) 您可以做两件事(或与)

  1. Use htaccess to stop users from running it 使用htaccess阻止用户运行它
  2. If the mandatory fields are not there, then don't save the form. 如果必填字段不存在,则不要保存表单。 Just check and stop execution on the first line. 只需检查并停止第一行的执行即可。

For more detailed help, you need to receiprocate and provide more details :-) 要获得更多详细的帮助,您需要提供回执并提供更多详细信息:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未从 PHP 处理 Html 表单 - Html form not being processed from PHP 如何阻止file_get_contents [PHP]的结果作为HTML处理? - How can I stop the result of file_get_contents [PHP] from being processed as HTML? 如何判断在php脚本中调用exit或die的位置 - How can I tell where exit or die is being called from within a php script 无法从HTML页面调用Javascript函数 - Javascript function not being called from html page 如何判断 PHP 脚本是由 AJAX 调用还是从浏览器调用? - How to tell if a PHP script is being called by AJAX or from the browser? 如何设置从PHP脚本调用交流程序的计时器? - How to set timer for a c program being called from php script? 我如何将变量从一个php传递到ajax调用的另一个变量,而前端看不到它 - How can I pass a variable from one php to another that's called by ajax without it being visible to the front end exec / system()-脚本被调用直到从PHP调用为止 - exec/system() - script being called works until called from PHP 如何在CodeIgniter中防止字段数据被转义并保留html和图像样式? - How can I keep field data from being escaped and preserve html and image styles in CodeIgniter? 如何判断是否从fetch()调用了页面? - How to tell if page is being called from a fetch()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM