News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Use SSI to display login boxes INLINE instead of stacked

Started by coopooc, October 07, 2005, 11:37:48 AM

Previous topic - Next topic

coopooc

Simple question I know, but I'm trying to figure out how to use CSS to display the login (username and password) boxes in a row instead of stacked on top of each other. Should be a simple thing but apparently I'm not smart enough to figure it out.  :(

I would like to avoid modifying the ssi.php file itself if possible.

Thanks

kegobeer

Don't call the login box at all.  If you include SSI.php in your php file, add this global after the include statement:

global $scripturl, $txt, $user_info;

Then display a custom login box if the person is a guest:

if ($user_info['is_guest']) {
  echo '
            <form action="', $scripturl, '?action=login2" method="post">
                 <input type="text" id="user" name="user" size="9" value="', $user_info['username'], '" />
                 <input type="password" name="passwrd" id="passwrd" size="9" />
                 <input type="hidden" name="cookielength" value="-1" />
                 <input type="submit" value="', $txt[34], '" />
            </form>';
}


Of course, you'll have to format the login stuff to meet your needs.  That should do what you want.  See the ssi example file for the proper way to include the SSI.php file into your php file.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

coopooc

Hot damn! Thanks kegobeer!

Just one question because I actually want to try to understand this a little bit. What does the global actually do?

Thanks againn.

kegobeer

I allows you access to variables from other files.  For instance, if you write a function that needs a variable declared at the beginning of the php file, you would include a global statement with the variable name, giving you access to the variable.

Check out www.php.net for a full explanation of the global statement.  I highly recommend browsing the php online documentation!
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

coopooc

kegobeer - I hate to do this to you but I'm having a very small problem with that piece of code you gave me. Everything is working great, I've figured out how to apply my stylesheet to the form box and buttons and it's looking great but for some reason, it looks as though that code is causing a hard return which breaks my table up. Can you tell me if any of those form elements would cause a <br> ? Thanks again.

By the way, here's the code, simple table, breaks after the login button...

  <tr>
    <td width="10" height="23"><img src="images/bottomleftcrnrtop.gif"></td>
    <td width="115" align="center" class="style1" bgcolor="#98C834">My Account</td>
    <td width="1" bgcolor="#FFFFFF"></td>
    <td width="570" height="23" bgcolor="#F1FCD2"><?php if ($user_info['is_guest']) { echo '
            <form action="'
$scripturl'?action=login2" method="post">
                 <input type="text" id="user" name="user" size="10" value="'
$user_info['username'], '" class="box" />
                 <input type="password" name="passwrd" id="passwrd" size="10" class="box" />
                 <input type="hidden" name="cookielength" value="-1" />
                 <input type="submit" value="Login" class="btn" /></form>'
;} ?>
<?php ssi_logout(); ?></td>

coopooc

Figured it out myself. Used display: inline in my CSS, took out the line break. Now if I can figure out how to accomplish the same thing as above with the Search form I'll be done!

Advertisement: