Jump to content

How to get current URL


smonkcaptain

Recommended Posts

The $_SERVER superglobal contains a lot of useful information about the URL, as well as many other things.

 

Look into the following (all related to the URL):

 

$_SERVER['REQUEST_URI'];

$_SERVER['PHP_SELF'];

$_SERVER['HTTP_HOST'];

$_SERVER['QUERY_STRING'];

$_SERVER['SCRIPT_NAME'];

 

As far as $_POST data is concerned, just access it using the $_POST or $_REQUEST superglobals.

Link to comment
Share on other sites

Thanks for the reply, I will take a look.

 

Maybe i havent specified the question too well;

 

Basically, people use my form to search my photodatabase.

 

I'm using $_POST to send data from the form to the query on the results page.

 

If i was to use $_GET i'd have a rather messy URL after anyone searched.. for example:

 

results.php?aircraft=747&airline=BritishAirways&blah=etc....

 

Hence choosing to use $_POST because it means whatever the search, the url will always be just search.php.

 

However, When a user clicks on a result, it goes to a new page, and i what to be able to have a 'back' button which then takes them back to the results page with the correct search criteria they have choosen.

 

Is this only possible with $_GET?

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.