Jump to content

Passing an "action" in the url.


overlordofevil

Recommended Posts

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

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");
}
?>

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'].

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.