overlordofevil Posted January 3, 2010 Share Posted January 3, 2010 Ok so as the title stated I am passing an action in the url and I programmed everything in php4. now I am working with php5 and I can't figure out how to correct it. For example once the users selects to logout I have the following code set up session_unset(); session_destroy(); $_SESSION = array(); header("Location: index2.php?action=logout"); So as you see from the code I redirecting to another page and using an action to specify what I want it to do but once it goes to the page all I get is a blank screen. The next set of code is from index2.php with the action. if ($action ==='logout') { echo "<table align='center' border='0' width='25%'><tr><td> <font color=red><b>Thank you for using the NERO National DB.</b></font></td></tr> <tr><td><font color=red><b>You are now logged out.</b></font></td> </tr></table>"; include ("index.php"); } As you can see the if statement comes up and looks for the action result. I know with php4 if I used 3 of the equal signs the system would process the request correctly. I know something has changed but I don't know what and I am a bit frustrated right now. If someone would tell me what I can do to get this to work with php5 I would appreciate it. Thanks Bill Link to comment https://forums.phpfreaks.com/topic/186995-passing-an-action-in-the-url/ Share on other sites More sharing options...
Buddski Posted January 3, 2010 Share Posted January 3, 2010 Im not sure if your using $_GET at all but try this.. <?php $action = (isset($_GET['action']) ? $_GET['action'] : null); if ($action ==='logout') { echo "<table align='center' border='0' width='25%'><tr><td> <font color=red><b>Thank you for using the NERO National DB.</b></font></td></tr> <tr><td><font color=red><b>You are now logged out.</b></font></td> </tr></table>"; include ("index.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/186995-passing-an-action-in-the-url/#findComment-987465 Share on other sites More sharing options...
overlordofevil Posted January 3, 2010 Author Share Posted January 3, 2010 blargh.. why didn't i think of that.. completely forgot I had to use $_GET instead of just assuming that the value would be used... sigh... Thanks for the help... it's been a long day... Link to comment https://forums.phpfreaks.com/topic/186995-passing-an-action-in-the-url/#findComment-987467 Share on other sites More sharing options...
oni-kun Posted January 3, 2010 Share Posted January 3, 2010 Buddski's code is correct; $action ==='logout' , Does that use register_globals? You should never code in that manner. The method to get an argument from the url query is $_GET['id'], This can be also accessed in entirety by $_SERVER['QUERY_STRING']. Link to comment https://forums.phpfreaks.com/topic/186995-passing-an-action-in-the-url/#findComment-987469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.