Jump to content

Check for Variable in URL


fraser5002

Recommended Posts

Hi ,

 

I have a login page that i acces via www.mydomain.com/logib.php?last_visited_page.php

however the passed in variable last_visited_page.com is not always set .

 

once the login script has run , when the variable it is not set i would want jump to myaccount.php

otherwise jump to last_visited_page.php

 

How do i check for no variable beinf present and therefore jump to myaccount.php

 

Many Thanks

Fraser

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/226792-check-for-variable-in-url/
Share on other sites

To work this correctly you should have the url as something like mydomain.com/login.php?last=lastPage.php...

Then you can use the following to check if it exists and if so to use it.

 

<?PHP

  if(isSet($_GET['last'])) {
    $lastPage = $_GET['last'];
  } else {
    $lastPage = 'myaccount.php';
  }

?>

 

Obviously you may have to do some more checks to make sure the data is correct and valid, but that should give you a start :)

 

Regards, PaulRyan.

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.