chrisidas Posted July 11, 2011 Share Posted July 11, 2011 I've been trying to add a little quick form box to the top of my page. The login system that i used is not my script and i do find it quite confusing, but i've managed to work with it so far. I actually have a seperate log in page all together which works fine, but i wanted to add a little quick log in box to the top of my pages. The trouble i'm having though, is i cant seem to get it to go away once the user is logged in. Here's my code <?php if($session->logged_in){ echo "[<a href=\"members_system/process.php\">Logout</a>]"; } else{ } ?> <form method="POST" action="members_system/process.php"> <input type="text" name="user" class="quick-login-form" value="<?php echo $form->value("user"); ?>" /> <input type="password" name="pass" class="quick-login-form" value="<?php echo $form->value("pass"); ?>" /> <input type="hidden" name="sublogin" value="1"> <input type="submit" name="login" value="Login" class="quick-login-button" /><br /> </form> If i put the fom inside the <?php tags i get all kind of syntax errors, even if i change the "s for 's. Also, the form on my main log in page isnt inside the <?php tags anyway, but it still doesnt show when the user is logged in. Here's my code on the main log in page. <php if($session->logged_in){ echo "<h3>Logged In</h3>"; 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{ ?> <h1>Login</h1> <?php /** * 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" class="table"> <table border="0" align="left" cellpadding="3" cellspacing="0" class="table"> <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php 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> Is it something to do with it being in a table, or am i just missing something really simple? Help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/241690-how-to-make-form-box-not-show-when-logged-in/ Share on other sites More sharing options...
Andy11548 Posted July 11, 2011 Share Posted July 11, 2011 Try this: <?php if($session->logged_in){ echo "[<a href=\"members_system/process.php\">Logout</a>]"; } else { ?> <form method="POST" action="members_system/process.php"> <input type="text" name="user" class="quick-login-form" value="<?php echo $form->value("user"); ?>" /> <input type="password" name="pass" class="quick-login-form" value="<?php echo $form->value("pass"); ?>" /> <input type="hidden" name="sublogin" value="1"> <input type="submit" name="login" value="Login" class="quick-login-button" /><br /> </form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241690-how-to-make-form-box-not-show-when-logged-in/#findComment-1241339 Share on other sites More sharing options...
Kustom_Vegas Posted July 11, 2011 Share Posted July 11, 2011 for the first section, if that is your full code then you are missing a closing bracket as Andy pointed out. As for the second snippet of code, the first thing that I notice is that your opening php tag is not correct...should be <?php instead of <php That is if you pasted your code and didnt manually wirte it into the post Quote Link to comment https://forums.phpfreaks.com/topic/241690-how-to-make-form-box-not-show-when-logged-in/#findComment-1241389 Share on other sites More sharing options...
chrisidas Posted July 11, 2011 Author Share Posted July 11, 2011 Awesome, that works thanks! Cheers for the reply as well Kustom_Vegas. I did manually edit it yeah to change it to <?php from <? Quote Link to comment https://forums.phpfreaks.com/topic/241690-how-to-make-form-box-not-show-when-logged-in/#findComment-1241390 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.