tags:

views:

115

answers:

4

i have form action file in another directory but some file send to this action file and how to get url to send action

http://www.test.com

-> 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
+1  A: 

You could store the $_SEVER["HTTP_REFERER"] in a session or other variable and then use it when applicable.

Ólafur Waage
The problem when you store it in a session is that when you have multiple tabs open the page will not behave correctly anymore...
Homes2001
Yes that is correct. That's why i mention other variable.
Ólafur Waage
A: 

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 '/'

Homes2001
A: 

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.

Homes2001
A: 

'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.

GoutMaximum