z1haze Posted January 20, 2009 Share Posted January 20, 2009 hi i have a login form at the top of my website, and im trying to get the form to change when users are logged in. I know this is a commonly asked question and i have searched the forums.. but it seems like the script im using is different than others? and whenever i try to change anything it just goes to a blank white screen. But anyway.. I want the login form and pass form, forgot password, and register, to appear when user is not logged in. And when users are logged in.. i dont want any of that to be visible.. just a simple welcome username. Currently the login thing at the top of the page works correctly.. but whenever the user logs in.. it still just says username: login box, and pass: login box. it doesnt change to anything.. how do i do this? this is maybe the code the script uses in a different login box maybe this can help <?php /** Users Box **/ /** Not logged in **/ if (!$_SESSION[$prefix.'logged_user']) { ?> <?php echo WELCOME; ?> <span class="blue">Guest</span><br /> <?php echo TODAY; ?> <?php echo date("D d m Y"); ?><br /> <br /> <div style="text-align:left;"> <form action="index.php?page=login" method="post" name="login"> <?php echo STND_USERNAME; ?><br /> <input type="text" name="username" class="standardforms"/><br /> <?php echo STND_PASSWORD; ?><br /> <input type="password" name="password" class="standardforms"/><br /> <br /> <?php /** Show captcha **/ if(ANTISPAM==1) { ?> <img src="CaptchaSecurityImages.php?width=125&height=40&characters=8" /><br/> <?php echo FORM_COPY; ?><br /> <input type="text" name="security_code" class="standardforms"/><br /> <?php } ?> <br /> <input type="submit" name="login" class="standardforms" value="<?php echo FORM_LOGIN; ?>"/> </form> </div> <ul> <li><a href="index.php?page=register"><?php echo STND_REGISTER; ?></a></li> <li><a href="index.php?page=login"><?php echo STND_LOGIN; ?></a></li> <li><a href="index.php?page=forgot"><?php echo STND_FORGOT; ?></a></li> </ul> <?php }else{ $result = mysql_query("SELECT * FROM members WHERE id = '".$_SESSION[$prefix.'user_id']."'") or die (mysql_error()); $row = @mysql_fetch_array($result); ?> <span style="float:left;"><?php echo WELCOME; ?> <?php echo flags($row['country'])." ".usernames($_SESSION[$prefix.'logged_user'], $_SESSION[$prefix.'logged_rank']); ?></span> <span style="float:right;"><?php echo TODAY; ?> <?php echo date("D d m Y"); ?></span> <br /><br /> <?php /** Private messages **/ $pm = mysql_query("SELECT * FROM pm WHERE pm_to = '".$_SESSION[$prefix.'user_id']."' AND pm_read = '0' AND outbox ='0'") or die (mysql_error()); $pm = mysql_num_rows($pm); $pm_total = mysql_query("SELECT * FROM pm WHERE pm_to = '".$_SESSION[$prefix.'user_id']."' AND outbox = '0'") or die (mysql_error()); $pm_total = mysql_num_rows($pm_total); ?> <?php echo avatars($row['id'], 80, 80); ?> <ul> <li><a href="user/index.php?p=pm"><?php echo ADMIN_PMS; ?></a> (<?php echo $pm_total; ?>) <?php if($pm>0) { echo "<span style='text-decoration:blink;'>".ADMIN_PMS_NEW."</span>"; } ?></li> <li><a href="index.php?page=members&id=<?php echo $_SESSION[$prefix.'user_id']; ?>"><?php echo MEMBER_PROFILE; ?></a></li> <li><a href="user/"><?php echo MEMBER_PANEL; ?></a></li> <li><a href="index.php?page=login&action=logout"><?php echo LOGOUT; ?></a></li> <?php /** Admin news rank **/ $rank = $_SESSION[$prefix.'logged_rank']; $usergroup = mysql_query("SELECT * FROM usergroups WHERE usergroup_id = '$rank'") or die (mysql_error()); $usergroup = @mysql_fetch_array($usergroup); if ($usergroup['permission_admin'] == 1) { ?> <li><a href="admin/"><?php echo ADMIN_PANEL; ?></a></li> <?php } } ?> </ul> keep in mind i only want to use a small portion of the feature.. i dont want any of the other links to be visible except maybe a logOUT link in place of the forgot password link or something.. thanks a lot Quote Link to comment Share on other sites More sharing options...
gevans Posted January 20, 2009 Share Posted January 20, 2009 There is an if statement checking the following session; $_SESSION[$prefix.'logged_user'] to see if a user is looged in or not, so if you are correctly calling start_session() and are checking the correct name for the logged in session the script should be working fine. Quote Link to comment Share on other sites More sharing options...
z1haze Posted January 20, 2009 Author Share Posted January 20, 2009 i dont know how to do that though.. the code that i posted, i pulled from the actual "login module" or block or whatever u call it.. I have a separate login at the top of the page by the banner to make it easier to login and out. the login works, it just doesnt change when users log in or log out.. its always the same. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted January 20, 2009 Share Posted January 20, 2009 If you are still copying and pasting code you "find" then I suggest going to php.net and reading. Ppl here are much more willing to help if the person being helped puts some effort into learning the language. Quote Link to comment Share on other sites More sharing options...
z1haze Posted January 20, 2009 Author Share Posted January 20, 2009 i bought the lynda php movie.. its tough though.. im learning but its tough Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.