I have made an include called authusers.php which I will be calling on everypage to check if the user is auth'd or not on my whole site (non-vB pages too). This is so I can display unique content to my visitors...
Here is the code up to now:
PHP Code:
<?php //authusers.php
//include global.php
$curdir = getcwd ();
chdir('/home/sion/public_html/forums/');
include_once ('global.php');
chdir ($curdir);
// check if logged in
if ($bbuserinfo['userid']== 0) {
?>
<table border="0" cellpadding="0" cellspacing="0">
<form action="member.php" method="post">
<tr>
<td nowrap><smallfont><b>Not cookied?</b><br>Login with username and password:</smallfont></td>
</tr><tr>
<td nowrap><input type="hidden" name="s" value="$session[sessionhash]">
<input type="hidden" name="action" value="login">
<input type="text" class="bginput" name="username" size="7">
<input type="password" class="bginput" name="password" size="7">
<input type="submit" class="bginput" value="Login!"></td>
</tr>
</form>
</table>
<?php
} else {
echo 'you are logged in';
}
?>
I've just put the echo 'you are logged in'; to test if the script actually works, which it does.
This is what I'm trying to achieve: I include this php file in every page, and if the user is logged in, then it shows the rest of the page (eg. membersonly.php), otherwise (if the user is a guest) it only shows the login form above.
I hope you understand what I mean, ask me any Qs if anything needs clarifying.
Thanks in advance!
--Sion---