AyDee AyDee - 1 year ago 105
PHP Question

Get the current inputed value parameter (PHP)

How can I get the current inputed value of my parameter in url?
for example this is my url


when I input a value in the redirect parameter for example is


how can I get that value of redirect?

Answer Source

The above comments are correct, but I wanted to take a second to explain why and provide some useful links.

$redirect = (isset($_GET['redirect'])) ? $_GET['redirect'] : false

Through this superglobal, you can access any parameter included in the URL. The values passed to you through this are urlencoded. YOu can read more about it here

What we did in the code above is this: - Check if the redirect param hasbeen filled (you could aso just use empty() below ) - Assign the redirect value to our $redirect variable if it is set, otherwise assign it false.

Using that, you can redirect the user there if it's set:

if($redirect) {
  header("Location: ".$redirect);

The downvote above isn't mine, but this isn't such a great question. I understand that you are new to the network, and everyone has to start somewhere. Please try to make sure you include code samples and do a bit of research yourself prior to your next question on SO.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download