Reputation: 5361
Here is what I'm dealing with:
Let's say I have some php page:
<?php
// do php stuff
?>
And I have two HTML pages where the action sends them to this php page. On this php page, I want it to do one thing if it comes from one of the html pages, and something else if it comes from the other. I cannot pass any explicit variables to the php page, I need to check which page called the php.
I have tried:
$_SERVER['PHP_SELF']
when I access this, it doesn't seem the send the referring page.
$_SERVER['HTTP_REFERER']
this gives the previous page to the one im looking for.
For example:
HTML PAGE1
form calls php
page --> I want some variable in PHP that contains HTML PAGE1
.
HTML PAGE2
form calls php
page --> I want some variable in PHP that contains HTML PAGE2
.
Thanks for the help. Please let me know if there's some way I can clarify the question.
Upvotes: 1
Views: 2805
Reputation: 598
As Think Different said a hidden field in your form is probably your best bet because you don't want to modify the url. In this case you would have the form submit over a POST request and retrive your data with $page = $_POST['YOUR_HIDDEN_VARIABLE_HERE']
.
Upvotes: 1
Reputation: 4715
If the domain differs you can use:
$_SERVER['SERVER_NAME'];
But in all scenarios this would help:
$_SERVER['REQUEST_URI'];
Giving you the complete URL that was called.
Upvotes: 2