简体   繁体   中英

How to know which page sent data in php

我想知道是否有可能知道哪个页面将POST数据传递到php脚本示例,而页面http://example.com/abc.html将POST数据发送到http://example.com/abc.php,因此预定义或用户定义的函数应由abc.php返回example.com/abc.html

Yes. Check the Referer header. $_SERVER['HTTP_REFERER']

Note that this can be spoofed by the client easily, and sending the header isn't required.

您可以使用将随POST传递的隐藏输入变量,作为标头响应的替代方法:

<option type="hidden" name="mypage" value="abc">

隐藏字段是有意义的,但是在每个页面上创建一个变量来命名似乎更容易,这样您就可以使用php变量使用if和else语句返回正确的信息,该信息基于从其发送的页面

you can do it by Simply using Referer header. ie $_SERVER['HTTP_REFERER']

example :echo $_SERVER ['HTTP_REFERER']; will print the link you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM