1

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
asked Apr 30, 2009 at 8:40

4 Answers 4

1

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

answered Apr 30, 2009 at 8:42
Sign up to request clarification or add additional context in comments.

1 Comment

The problem when you store it in a session is that when you have multiple tabs open the page will not behave correctly anymore...
0

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

answered Apr 30, 2009 at 8:46

Comments

0

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.

answered Apr 30, 2009 at 8:52

Comments

0

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

answered Apr 30, 2009 at 9:24

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.