thelung
09-16-2011, 05:49 AM
I'm trying to put together a website for which I've already gotten the design figured out and coded up.
I'm using a lot of php includes to call files with content and forms on the various pages. But, I want to add php sessions to some of the pages to restrict privileges to only registered users.
I know this is very basic, but I'm hung up on something. I'm sure that half of my battle is my terrible syntax. But, even with that being said, I don't know how this is done.
Do I need to 'echo' the html tags (numerous tags) individually into the if statement or can i break the if/else statement like
<? php if ($_SESSION['username'])
{ ?>
<div id = "blocks_of_phpIncludes">
<? include '../form/muliple.php'; ?>
<? include '../tables/foo.php'; ?>
</div>
}
<? else{
<div id = "blocks_of_phpIncludes">
<? include '../forms/signIn.php'; ?>
</div>
}
?>
Is there some way of doing something like this? Or, do I just need to start with <?php and echo everything into their respective places throughout each page that will require the session be set?
I'm using a lot of php includes to call files with content and forms on the various pages. But, I want to add php sessions to some of the pages to restrict privileges to only registered users.
I know this is very basic, but I'm hung up on something. I'm sure that half of my battle is my terrible syntax. But, even with that being said, I don't know how this is done.
Do I need to 'echo' the html tags (numerous tags) individually into the if statement or can i break the if/else statement like
<? php if ($_SESSION['username'])
{ ?>
<div id = "blocks_of_phpIncludes">
<? include '../form/muliple.php'; ?>
<? include '../tables/foo.php'; ?>
</div>
}
<? else{
<div id = "blocks_of_phpIncludes">
<? include '../forms/signIn.php'; ?>
</div>
}
?>
Is there some way of doing something like this? Or, do I just need to start with <?php and echo everything into their respective places throughout each page that will require the session be set?