login - Changing an output for a link in php -
i'm trying link in menu change once user logged in. meaning "my page" displayed, rather "log in". now, user can log in , log out. yet name/link not change directly after user logged in.
my code menu: (i use include('menu.php' on sites. flexibility of code)
<div id="menu"> <ul> <li><a href="index.php">home</a></li> <li><?php echo $mypage?></li> <li><a href="community.html">community</a></li> <li><a href="media.html">media</a></li> <li><a href="contact.html">contact</a></li> </ul>
my code config.php:
<?php session_start(); $mypage; if(isset($_session['name'])) { $mypage = '<a href="mypage.php">my page</a>'; } else { $mypage = '<a href="login.php">log in</a>'; } ?>
only when user clicks on menu $mypage variable update. i've tried refreshing page header() function. lead redirection-loop.
it great if me out.
edit
to clear things up:
for better understanding of website: http://www.askmephilosophy.camilstaps.nl/ (the thing can viewed (so far) 'welcome' , 'log in'. after login redirected mypage.php site. (this can accessed typing after name. */mypage.php)
so if understand: 1/ log-in 2/ logged name stay "log in" 3/ refresh page menu changes "my page"
i think set $_session['name'] after execute
if(isset($_session['name'])) { $mypage = '<a href="mypage.php">my page</a>'; } else { $mypage = '<a href="login.php">log in</a>'; }
try this:
if (isset ($_post['name']) && isset ($_post['password']) && ($_post['password'] == $hash)) { $_session['name'] = $_post['name']; } if(isset($_session['name'])) { $mypage = '<a href="mypage.php">my page</a>'; } else { $mypage = '<a href="login.php">log in</a>'; }
Comments
Post a Comment