Hi, I have a login system this is the code

<table>
<tr><td>


<?php
/**
 * 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>] &nbsp;&nbsp;"
       ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
   if($session->isAdmin()){
      echo "[<a href=\"admin/index.php\">Admin Center</a>] &nbsp;&nbsp;";
   }
   echo "[<a href=\"process.php\">Logout</a>]";
echo "<br><br>";
include("include/view_active.php");
}
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 $form->num_errors." error(s) found";
}
?>
<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="<?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" <?php if($form->value("remember") != ""){ echo "checked"; } ?>>
Remember me &nbsp;&nbsp;&nbsp;&nbsp;
<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>

</td></tr>
</table>

<?php
}
?>

And I want it like this. This login does not have any .css and I want it to be like this...

Login: |_____________________| Password: |_________________________| Register|Forgot Password.

Please can someone help Fast.

Dani AI

Generated

The table-based layout in the original post makes the form hard to keep on a single line. As advised, replace presentation tables with semantic markup and CSS. 's inline idea points the right way; below is an accessible, responsive pattern that keeps the fields and links on one line on wide screens and stacks them on small screens. Preserve whatever input names and hidden fields the existing PHP processing expects (do not drop server-side fields).

Example HTML (replace placeholders with the exact action and names your server expects):

<form class="login-inline" action="[your-processing-endpoint]" method="post">
  <label class="login-field">Login
    <input type="text" name="username" />
  </label>

  <label class="login-field">Password
    <input type="password" name="password" />
  </label>

  <div class="actions">
    <button type="submit">Login</button>
    <a href="[register-url]">Register</a>
    <a href="[forgot-url]">Forgot Password</a>
  </div>
</form>

Minimal CSS using Flexbox (put this in a stylesheet, not inline):

.login-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap; /* allows wrapping on narrow viewports */
}

.login-field {
  display: flex;
  align-items: center;
  gap: 6px;
}

.actions {
  margin-left: auto; /* pushes links to the right on wide screens */
}

/* stack on small screens */
@media (max-width: 520px) {
  .login-inline { flex-direction: column; align-items: stretch; }
  .actions { margin-left: 0; }
}

Troubleshooting notes: inspect the form in browser devtools to confirm inputs are inline (check computed display and flex settings). If server-side validation injects error text, give errors an .error class and style them to appear beside or below the related input. For accessibility, use labels (or for + id) so screen readers announce inputs correctly — see MDN on the label element and Flexbox for implementation details: MDN: label element and MDN: Flexbox.

Recommended Answers

All 5 Replies

Just remove the TALBEs, TRs an TDs .
You don't need a table to do that.

I'm sorry if i didn't understood the question well.

Member Avatar for Member #120589

SO what's the problem? Doesn't it display the way you show it above?

You want CSS help or help with the PHP? You've posted to the PHP forum, so I'm assuming it's to do with the php code. Could you give an idea of the problem?

Sorry, I had thought it was css. Because I am used to posting in php. Really Sorry please could you move it to css. and yes it might be css because I want the login forms and links to be like on 1 line instead of quite a few. like Login: ................. password:................... forgot pass|register. Like that instead of a big chunk.

Now please can someone help

Hi,

Try this (simplified manner) :

<form action="process.php" method="POST">
    Username:<input type="text" name="user" maxlength="30" value="" />Password:<input type="password" name="pass" maxlength="30" value=""/>Register | Forgot password
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.