DylanC Posted February 1, 2008 Share Posted February 1, 2008 I have the following script.. <? /** * User has already logged in, so display relavent links, including * a link to the admin center if the user is an administrator. */ if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>, you are logged in. <br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]"; } else{ ?> <p class="headtext">Sign In</p> <p style="font-size:11pt;">bleh</p> <? /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){ echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>"; }} ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr> <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>> <font size="2">Remember me next time <input type="hidden" name="sublogin" value="1"> <input type="submit" value="Login"></td></tr> <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr> <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr> </table> </form> If the user is logged in, is it possible to hide that html form? Quote Link to comment https://forums.phpfreaks.com/topic/88975-hiding-form-if-logged-in/ Share on other sites More sharing options...
A2xA Posted February 1, 2008 Share Posted February 1, 2008 I know on mine I just re-direct the user if they aren't logged in to the login page. I'm not sure if this is right but.... Maybe something like this? <?php if ($context['user']['is_guest']) echo "Sorry you must be logged in"; } else { <html> FORM YOU DON'T WANT VISIBLE </html> } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88975-hiding-form-if-logged-in/#findComment-455661 Share on other sites More sharing options...
A2xA Posted February 1, 2008 Share Posted February 1, 2008 erm wait. I did this backwards just a sec. Change the ['guest] to whatever your user context is. And the echo to whatever you would like. Quote Link to comment https://forums.phpfreaks.com/topic/88975-hiding-form-if-logged-in/#findComment-455664 Share on other sites More sharing options...
revraz Posted February 1, 2008 Share Posted February 1, 2008 Put your form code in the ELSE { } brackets instead of outside of it. Quote Link to comment https://forums.phpfreaks.com/topic/88975-hiding-form-if-logged-in/#findComment-455690 Share on other sites More sharing options...
A2xA Posted February 1, 2008 Share Posted February 1, 2008 ah, my bad I'm still learning. I knew it was something like that. Quote Link to comment https://forums.phpfreaks.com/topic/88975-hiding-form-if-logged-in/#findComment-455699 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.