开发者

How do I identify where the POST data sent to a PHP script came from?

开发者 https://www.devze.com 2022-12-29 21:21 出处:网络
I have a ton of data collection forms on my website, and I wrote a PHP script to handle all the data.All the forms have that one script as their action, and POST as the method.The handler emails a cop

I have a ton of data collection forms on my website, and I wrote a PHP script to handle all the data. All the forms have that one script as their action, and POST as the method. The handler emails a copy of the data to me, and I'd like for the emails I get to contain the URL of the form where they originated. Is there any way in PHP to get the url of the form which was submitted to the script? Or do I have to add an extra hidd开发者_开发问答en field in every form with its URL?


Send the following variable in the email as well:

$_SERVER['HTTP_REFERER'] 


If you want to ensure that posts only arrive from your own form, you could put a one-time token on the form in a hidden field to validate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号