Hmm.. not sure why, check this?
I just realised, you aren't checking if anything is set.. You check if username is empty but you haven't processed it.. (make sense??)PHP Code:<?php
session_start();
//require_once('config.php');
if($_SESSION['username']) {
die('You are already logged in.');
} else {
if($_POST['login']){ // check if the form has been submitted
$username = clean($_POST['username']);
$password = clean(encrypt($_POST['password']));
if(isset($username) || isset($password)){
die('You left a field blank. Please go <a href="login.php">back</a> and fix it.');
} else {
$checklogin = mysql_query("SELECT * FROM users WHERE Username = '{$username}' AND Password = '{$password}'");
$num_rows = mysql_num_rows($query);
// Check if the login was successful. (1 = succesfull)
if($num_rows == 1) {
$row = mysql_fetch_array($checklogin);
$email = $row['email'];
$uid = $row['id'];
$_SESSION['username'] = $username;
$_SESSION['loggedin'] = 1;
echo 'Welcome to TrueHabbo Faces, <b>'.$_SESSION['username'].'</b>. Click <a href="index.php">here</a> to go back to the main page.';
} else {
echo 'Your password did not match the specified username.';
}
}
} else { // since it wasn't submitted yet, show the form.
echo ("<form method=\"post\">
Username: <br>
<input name=\"username\" type=\"text\">
<br><br>
Password: <br>
<input name=\"password\" type=\"text\">
<br><br>
<input type=\"submit\" name=\"login\" value=\"Login\">
");
}
}
?>
i updated the code to fix it i think.


Reply With Quote


