I don't think that will work cause of how i have the pages setup. I have a header.php which which is included in the index.php file. That checks whether or not the cookie is set to allow =1 and will display the users online if it is.
Im thinking it is a backeting issue but im not certain. Here is the code for the header.php:
<?php error_reporting(0);
$uname ='test';
$pass ='test';
?>
// Some html here
<?php
if (isset($_POST['go'])){
if ( ($_POST['uname'] == $uname) && ($_POST['pass'] == $pass) ) {
setcookie("allow", 1, time() + (86400 * 30));
}
if ($_COOKIE["allow"] == 1) {
include ("online.php");
}
}
?>
And then the index.php which the form is submitting to:
<?php
if (!$_COOKIE['allow']) { ?>
<form action=index.php method="post"><br />
<?php if ( isset($_POST['check']) && ($_POST['uname'] !== $uname) ) {
echo "Username Incorrect <br />";
} //endif
?>
Username: <input name="uname" type="text" size="10" maxlength="10" value="<?php $_POST['uname'] ?>" /><br /><br />
<?php if ( isset($_POST['check']) && ($_POST['pass'] !== $pass) ) {
echo "Password Incorrect <br />";
} //endif
?>
Password:
<input name="pass" type="password" size="10" maxlength="10" value="<?php $_POST['pass'] ?>" /><br />
<input name="go" type="submit" value="Login" />
<input type="hidden" name="check" >
</form>
<?php } ?>
It all works just that you have to hit the login buton 2x before the users online will show and the form disappears.