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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple question from a newbie

Status
Not open for further replies.

benluke4

Technical User
Jan 27, 2005
127
GB
Hi, how do i add and if ($_SESSION['username']) to the code below so that it only lets users in if they have the correct area session registered and have a username session registered aswell. I keep getting errors

Thanks for any help

Bne

Code:
$area_check="area300";
if ($_SESSION['area']!=$area_check){
header ("Location: login.php");
exit();
} else {}
 
you need to start the session (session_start()) before testing the session variables.
 
reply yea sorry just posted fragment of the code here is the full piece

Code:
<?
// checks that user is logged in
session_start();
header("Cache-control: private"); 

$area_check="area300";
if ($_SESSION['area']!=$area_check){
header ("Location: login.php");
exit();
} else {}
?>
 
code looks ok. what errors are you getting?
 
im not getting any errors.... at the moment.

i just wanted to add if ($_SESSION['username']) to the code so that it only lets users in if they have the correct area session registered and have a username session registered aswell.

sorry i might not have been clear

Thanks

Ben
 
aha

Code:
if ($_SESSION['area']!=$area_check
    &&
    isset($_SESSION['username']))
{
  header ("Location: login.php");
  exit();
} else {}
?>
 
hi there ,
how do I save data from a html form to a txt file and where does the php fits in all that

 
I can't hardly imagine a question more broad than the one you asked. You should consider reading up on the basic concepts in the PHP manual or on tutorial sites. If you come up with a more specific technical question after that you'll probably get good answers.
Your last question was a good one. This one - bad.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top