D-Man22
03-09-2010, 01:50 PM
Okay... so... The sessions are not staying when a user logs in...
here's my "login.php"
<? session_start();
include('database.php');
require "functions.all.php";
if(!isset($_SESSION['loggedin'])){
if(!isset($_POST['loginOK'])){
displayLoginForm();
//Probably gonna call a display class here
}else{
processLogin();
}
}else{ echo "Hello, ".$_SESSION[user].". And welcome to the user system."; }
?>
here is the 2 functions....
function displayLoginForm()
{
echo '<div style="padding-left: 5px;">
<form method="post" name="loginForm" onsubmit="myHabbio.__doLogin();return false;">
<b>Username:</b><br /> <input type="text" name="username" id="username" class="oo" /><br />
<b>Password:</b><br /> <input type="password" name="password" id="password" class="oo" /><br />
<input type="submit" id="loginOK" style="margin-top:3px;" value="Login »" name="sOK" onclick="myHabbio.__doLogin();return false;" class="oo" /> or FB_connect()<br />
No account? <a href="my1/register.php">Register for free!</a>
</form>
</div>
';
}
//////////////////////
function processLogin() {
$username = $_POST['username'];
$password = sha1($_POST[password]);
$exsists = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `username`='" . $username . "'"));
if($exsists == 0){ throwLoginError('Incorrect username/password</b><br />Please try again'); }
else{ $result = mysql_query("SELECT * FROM users
WHERE username='$username'") or die();
$row = mysql_fetch_array( $result );
$password1 = sha1($row[password]);
if($password == $password1){ $_SESSION['user'] = $username; $_SESSION['loggedin'] == 1;
//I have ^^ The sessions set there... but when the user reloads the page, it displays the login form =/
displayUserBox();
}else{ throwLoginError('Incorrect username/password</b><br />Please try again'); }
}
}
When a user logs in; i have it set the sessions and display the "userbox".... but when I refresh the page, the login form is displayed... even though the seesions were already set. HELP :/
here's my "login.php"
<? session_start();
include('database.php');
require "functions.all.php";
if(!isset($_SESSION['loggedin'])){
if(!isset($_POST['loginOK'])){
displayLoginForm();
//Probably gonna call a display class here
}else{
processLogin();
}
}else{ echo "Hello, ".$_SESSION[user].". And welcome to the user system."; }
?>
here is the 2 functions....
function displayLoginForm()
{
echo '<div style="padding-left: 5px;">
<form method="post" name="loginForm" onsubmit="myHabbio.__doLogin();return false;">
<b>Username:</b><br /> <input type="text" name="username" id="username" class="oo" /><br />
<b>Password:</b><br /> <input type="password" name="password" id="password" class="oo" /><br />
<input type="submit" id="loginOK" style="margin-top:3px;" value="Login »" name="sOK" onclick="myHabbio.__doLogin();return false;" class="oo" /> or FB_connect()<br />
No account? <a href="my1/register.php">Register for free!</a>
</form>
</div>
';
}
//////////////////////
function processLogin() {
$username = $_POST['username'];
$password = sha1($_POST[password]);
$exsists = mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `username`='" . $username . "'"));
if($exsists == 0){ throwLoginError('Incorrect username/password</b><br />Please try again'); }
else{ $result = mysql_query("SELECT * FROM users
WHERE username='$username'") or die();
$row = mysql_fetch_array( $result );
$password1 = sha1($row[password]);
if($password == $password1){ $_SESSION['user'] = $username; $_SESSION['loggedin'] == 1;
//I have ^^ The sessions set there... but when the user reloads the page, it displays the login form =/
displayUserBox();
}else{ throwLoginError('Incorrect username/password</b><br />Please try again'); }
}
}
When a user logs in; i have it set the sessions and display the "userbox".... but when I refresh the page, the login form is displayed... even though the seesions were already set. HELP :/