Jump to content

session help!


phpwiz

Recommended Posts

Ok i made a site with a login and register script and it all works perfectly and stuff but i dont what to echo every single bit of my content. it will make sense after i post the code.

 

<?php 

if ($_SESSION['username'])
echo "Welcome, ".$_SESSION['username']."!";
        echo "all the current content";

else
die("Sorry you are not logged in <a href='login.php'> Click here</a> to login");

?>

 

i want it so i dont have to post it in an echo, so i can just post

 

content

 

instead of:

 

echo "content";

 

can someone please help me with this problem!!!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/169886-session-help/
Share on other sites

You need to explain what your trying to do.

 

i thought it over and would something like this work?

 

<?php 

if ($_SESSION['username'])
echo "Welcome, ".$_SESSION['username']."!"; ?>
content here
<?php
else
die("Sorry you are not logged in <a href='login.php'> Click here</a> to login");

?>

test

 

 

Link to comment
https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896221
Share on other sites

Brackets, brackets, brackets.

 

<?php 

if ($_SESSION['username'])
{
    echo "Welcome, ".$_SESSION['username']."!"; 
?>
content here
<?php
}
else
{
    die("Sorry you are not logged in <a href='login.php'> Click here</a> to login");
}
?>

test

 

WOW i cant belive i missed that  :facewall:

Link to comment
https://forums.phpfreaks.com/topic/169886-session-help/#findComment-896229
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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