Jump to content

Recommended Posts

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 :)

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
}
?> 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.