Home >Backend Development >PHP Tutorial >PHP obtains the URLs of the first two pages by hiding the form control, form URL_PHP tutorial
I also encountered similar problems during my study:
For example, the background wants to look like this:
But the actual situation is like this:
Solution:
By hiding form controls
<input type="hidden" name="prevurl" value="<?php echo $_SERVER['HTTP_REFERER']?>">
In this way, the value of $_SERVER['HTTP_REFERER'] seems to be temporarily stored in $_POST[prevurl].
In fact, the principle of this method is to post the previous URL to another place through the post method, but this post is the current page
In the future development, there will be a select tag in the newly created article. If the select tag is disabled, the selected value will not be posted, so I once again used the hidden deception method and submitted it secretly. Once, tried and true.
PHP $_SERVER['HTTP_REFERER']
Using $_SERVER['HTTP_REFERER'] will easily get the address of the previous page linked to the current page.
$_SERVER['HTTP_REFERER'] is only valid for pages accessed via 3499910bf9dac5ae3c52d5ede73834855db79b134e9f6b82c0b36e0489ee08ed hyperlinks and POST or GET forms.
Except for pictures, you can use URL to pass variables
The acquisition method is such as a.php?a=123
Then use $_GET['a'] to output
If there are multi-level variables You can use a.php?a=123&b=456&c=789
echo $_GET['a'] 123 echo $_GET['b'] 456
Write a function to filter the best variables to ensure Web Security
In fact, even if you use GET, you can still use post to get the value in the form. If you don’t get it, you can check whether the post and get settings are turned off