coreysnyder04 Posted February 20, 2009 Share Posted February 20, 2009 I am building a website and I recently got the log-in working using sessions. 1. At the top of my pages I have an area with a log in form. I would like to check to see if they are logged in, if so display something like "Welcome USERNAME55555 | logout". That way you can tell if you are logged in or not, and have a way to log out. Anyone know how to accomplish this? 2. Lets say I get the above problem working. I don't want to have to go and add that code to EVERY page on my site. There has to be a much better way about handling changes that will appear on every page. Whats the best way to do setup your site to where you can make big changes very easily? 3. How do you pull data out of a session? Thanks, Corey Link to comment https://forums.phpfreaks.com/topic/146041-nooby-phphtml-questions/ Share on other sites More sharing options...
samshel Posted February 20, 2009 Share Posted February 20, 2009 1. At the top of my pages I have an area with a log in form. I would like to check to see if they are logged in, if so display something like "Welcome USERNAME55555 | logout". That way you can tell if you are logged in or not, and have a way to log out. Anyone know how to accomplish this? -> http://us.php.net/manual/en/book.session.php 2. Lets say I get the above problem working. I don't want to have to go and add that code to EVERY page on my site. There has to be a much better way about handling changes that will appear on every page. Whats the best way to do setup your site to where you can make big changes very easily? -> http://us.php.net/manual/en/function.include.php 3. How do you pull data out of a session? -> http://us.php.net/manual/en/book.session.php Manul has it all !! Best of Luck ! Link to comment https://forums.phpfreaks.com/topic/146041-nooby-phphtml-questions/#findComment-766667 Share on other sites More sharing options...
farkewie Posted February 20, 2009 Share Posted February 20, 2009 Hi, Here goes... 1. <?php //your session name will most likley be different. if ($_SESSION['loggedIn'] == true) { print "Welcome " . $_SESSION['username']; } else { //display login form } ?> As for the best way to minimize changes. There are a few option. you can include all you pages such as [code] <div id="header"><?php include 'header.php';?></div> <div id="lefnav"><?php include 'lefnav.php';?></div> <div id="content"><!-- display you content here--></div> <div id="footer"><?php include 'footer.php';?></div> or you can use a templating system like smarty. or you can have 1 page that is used for all content that is fully dynamic. http://myhost?page=home <?php if ($_GET['page'] == "home"){ //display home } ?> } Link to comment https://forums.phpfreaks.com/topic/146041-nooby-phphtml-questions/#findComment-766670 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.