Jump to content

$_GET issue


kapz22

Recommended Posts

Hi all, i need some help.

 

basiclly i am making a view page which has a an id in the URL i.e view.php?id=1

if no id is included in the url, it errors.  I fixed that by inserting the following code:

 

if (!isset($_GET["id"])){

$_GET["id"] = "";

}

 

but it still loads the page and has errors.

 

how do i need to change this code so that if ?id= is not in the url, it doesnt load the page? i.e. takes the user to the prvious page they were at.

Link to comment
https://forums.phpfreaks.com/topic/192765-_get-issue/
Share on other sites

im sure it can be done though, as i have seen it on websites, where if the url is not correct ie not containing the variables, it wont load the page at all.

 

You can make it 404 out if you want to, by including a custom 404 page. Not really sure what you are after. If you want it to be "blank" just remove my echo and it will just be a blank page. But the page will always load to check something, no matter what. It is the directions you give the code that make it "seem" like it does not load. 

Link to comment
https://forums.phpfreaks.com/topic/192765-_get-issue/#findComment-1015439
Share on other sites

They are most likely setting a session variable with the last id viewed or last page viewed. Then if no id is passed it reverts back to the session. Whether this was "coded" that way or not I do not know, as it may have been a mistake on their part in that they have register_globals turned on and if they stored the id in session, it would be set then.

 

Either way, using sessions you can easily achieve this.

Link to comment
https://forums.phpfreaks.com/topic/192765-_get-issue/#findComment-1015466
Share on other sites

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.