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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.