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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.