Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Flag ***Please Help*** 1

Status
Not open for further replies.

chuckbridges

Programmer
Apr 15, 2005
19
US
How do I create a temporary flag variable say $flag
that can be checked from one page to another using an if ($flag=="1"){ statement. I dont want to save it in the database but I still want to flag it and unflag it from time to time...



Thanks

Chuck
 
Use sessions.

At the beginning of each script (before anything is output to the screen), put the statement:
Code:
session_start();

Where you want to set your flag to TRUE, use:
Code:
$_SESSION['flag'] = TRUE; // or anything else

Where you want to test it:
Code:
if (isset($_SESSION['flag']) && $_SESSION['flag']))
// do something

To unset it:
Code:
unset($_SESSION['flag']);

More information about sessions can be found at
Ken
 
chuckbridges,

Are you simply trying to pass a variable value between different pages? You can do this by simply passing the value in the anchor tag.
Code:
<a href="filename.php?flag=1">text</a>

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
If you do it on the URL, you will be subject to user manipulation of the flag and you better have very tight controls over what the variable is allowed to contain.

If you use SESSIONS, user will not be able to (easily) change the value.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top