i have form action file in another directory but some file send to this action file and how to get url to send action
-> action to http://www.123456.com/ac.php
how to get http://www.test.com in http://www.123456.com/ac.php to goback http://www.test.com
4 Answers 4
You could store the $_SEVER["HTTP_REFERER"] in a session or other variable and then use it when applicable.
1 Comment
You might consider using the predefined php variables to find out the request URL like this:
$_SERVER['HTTP_HOST']
$_SERVER['REQUEST_URI']
But if you just want to redirect to the root of your host, then you can simply send a HTTP redirect to '/'
Comments
I think if you really want to be able to navigate back to the previous page it would be a good idea to post the URL of the current page along with the rest of the form data. That way you have access to that field on the next page and can render a link which sends the user back to the previous page...
You can use a hidden field to store the URL of the current page in the form.
Comments
'http://' . $_SERVER['SERVER_NAME']
I would not recommend using $_SERVER['HTTP_REFERER'] because it might be blocked by the visitors browser, firewall or antivirus. Not to mention the value might be wrong.