Add a login form over the header
From PunBB Resource Wiki
This article explains how to make a login form at the top of your pages like shown in the image.
Contents |
[edit]
login.php
First, create a file (login.php) in your include/user/ folder. The file should contain this:
<?php // Show login if not logged in if($pun_user['is_guest']) { if(!isset($focus_element) || (isset($focus_element) && !in_array('login', $focus_element))) { // Load the language files require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php'; require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php'; // Set the $redirect_url to this page, $redirect_url = '' ; if(isset($_SERVER['REQUEST_URI'])) $redirect_url = $_SERVER['REQUEST_URI'] ; $required_fields = array('req_username' => $lang_common['Username'], 'req_password' => $lang_common['Password']); ?> <div class="logintop"> <form id="login" name="login" method="post" action="login.php?action=in" onsubmit="return process_form(this)"> <p> <input type="hidden" name="form_sent" value="1" /> <input type="hidden" name="redirect_url" value="<?php echo $redirect_url ?>" /> <?php echo $lang_common['Username'] ?>: <input type="text" name="req_username" size="16" maxlength="25" /> <?php echo $lang_common['Password'] ?>: <input type="password" name="req_password" size="16" maxlength="16" /> <a href="#" onclick="document.login.submit(); return false"><?php echo $lang_common['Login'] ?></a> | <a href="register.php"><?php echo $lang_common['Register'] ?></a> </p> </form> </div> <?php } } else { ?> <div class="logintop"> <p> <?php echo $lang_common['Logged in as'].' <strong>'.pun_htmlspecialchars($pun_user['username']).'</strong> | <a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>'; ?> </p> </div> <?php } ?>
[edit]
Editing the templates
Open include/template/main.tpl and replace this:
<div id="brdheader" class="block"> <div class="box">
with this:
<div id="brdheader" class="block"> <pun_include "login.php"> <div class="box">
[edit]
Optional: Remove Login link
To remove the login link from the navigation, open up functions and locate these lines (in generate_navlinks()):
// (line 247) $links[] = '<li id="navlogin"><a href="login.php">'.$lang_common['Login'].'</a>'; // (line 259) $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>'; // (line 266) $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
Then simply comment them by putting // infront of them.
[edit]
Optional: Style it
You can style the box by adding this to your CSS file(s):
DIV.logintop{ /* Style your login box */ }
--Jansson 14:09, 15 April 2006 (GMT)

