question about echo statement with if statement

Hi I have a quick question about including an “include(’’)” statement in a set of code that is using echo and an if statement. The code does work if the include is removed, but I am not sure if it is even possible to have an include in the code.

here is the code:

<? /* User is not logged in */ if($_SESSION['id']) echo'

Hello, '.$_SESSION['usr'].' "Welcome to the Profile section of the website"

'; include('include/profile_content.php'); echo ' '; else echo' Protected Page Please Login

You re not alowed to login to this site, please login!

'; ?>

$_SESSION[‘id’] will write an error if it is not set,so better to check if it`s set
[php]

<?php if(isset($_SESSION['id'])){ ?>

Hello, <?php echo $_SESSION['usr']; ?> , Welcome to the Profile section of the website

<?php include('include/profile_content.php'); ?> <?php } else { ?> Protected Page Please Login

You re not alowed to login to this site, please login!

<?php } ?> [/php]

Thanks for the help, it worked exactly as you typed it. Again thanks for the help.

vincent.

Sponsor our Newsletter | Privacy Policy | Terms of Service