简体   繁体   English

检查用户是否从另一个页面重定向

[英]Check if user is redirected from another page

I have a <form> that sends the user to an external page: action="http:/example.com/test/test.php" . 我有一个<form> ,它将用户发送到外部页面: action="http:/example.com/test/test.php" The test.php on the external page executes an SQL query and sends the user to my internal page test2.php . 外部页面上的test.php执行SQL查询,并将用户发送到我的内部页面test2.php The second page test2.php also executes an SQL query and the process gets closed. 第二页test2.php也执行SQL查询,并且过程关闭。

I want to perform an check operation in test2.php . 我想在test2.php执行检查操作。 I only want to run the SQL query if the user is redirected from the external page. 如果用户是从外部页面重定向的,我只想运行SQL查询。

How can I do this? 我怎样才能做到这一点?

You can check the Referer header with $_SERVER['HTTP_REFERER'] to see what page they were redirected from. 您可以使用$_SERVER['HTTP_REFERER']检查Referer标头,以查看它们从哪个页面重定向。 This isn't reliable, though, since people can forge headers, but for the most part, if people are using browsers, you can use this to check if they were redirected. 但是,这并不可靠,因为人们可以伪造标题,但是在大多数情况下,如果人们正在使用浏览器,则可以使用它来检查它们是否已重定向。

为什么不使用像http://example.com/test/test.php这样的URL参数? redirect = true

Instead of having your form use a cross-domain action , perhaps you can have your PHP code use curl to submit the information to the foreign server. 与其让您的表单使用跨域action ,不如让您的PHP代码使用curl将信息提交到外部服务器。 Then your PHP code will know exactly what happened. 然后,您的PHP代码将确切知道发生了什么。

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

相关问题 检查用户是否来自另一个页面 - Check if user is coming from a another page Vue 3成功登录后如何将用户重定向到另一个页面 - How should a user be redirected to another page after successful login in Vue 3 react js用户在刷新时被重定向到另一个页面 - react js user gets redirected to another page on refresh 检查是从主页还是从子页面重定向的方法 - Way to check were you redirected either from a main page or subpage 从另一个页面重定向时,视差不起作用? - Parallax not working when being redirected from another page? javascript不带用户到重定向页面 - javascript not bringing user to redirected page 页面重定向到另一个页面(仪表板)后如何使用Firebase身份验证用户数据? - How to use firebase authentication user data after the page is redirected to another page (dashboard)? 页面重定向到另一个页面后输入凭据 - enter credentials after the page is redirected to another page Puppeteer 如何检查页面是否已重定向 - Puppeteer How to check if the page has redirected 提交表单后从另一个页面(如确认页面)重定向后,如何将值保留在表单中 - How to keep the values in a form after getting redirected from another page(like a confirmation page) after submitting the form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM