i made a log in form in header on the top right side with the other contents like search bar and logo
and i have a plan when i logged in the other headers content is stand still but only the log in content is changing to the Logged in content
and here is my code that i assume have no problem at all
PHP code
if(empty($_POST) === false){
$username = $_POST['input-username'];
$password = $_POST['input-password'];
if(empty($username) === true || empty($password) ===true){
$errors[] = 'You Need To Enter a Username And a Password';
}
else if(user_exists($username) === false){
$errors[] = 'We Can\'t Find That Username';
}
else{
$login = login($username, $password);
if($login === false){
$errors[] = 'Your Username and Password Combination is Incorrect';
}
else{
$_SESSION['user_id'] = $login;
header("Location: index.php");
}
}
print_r($errors);
}
HTML Script
<form method="post" action="index.php" name="signin-form">
<table border="1">
<tr>
<td>Username</td><td><input type="text" name="input-username" id="input-username"></td>
<td>Password</td><td><input type="password" name="input-password" id="input-password"></td>
<td>
<input type="submit" name="sign-in" id="sign-in" value="Log in">
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="remember-me">
<label id="information">Keep Me Eating Picture</label>
</td>
<td colspan="2">
<a href="#" id="forgotpass">Forgotten My Username or Password</a>
</td>
</tr>
</table>
</form>
but somehow the condition is getting weird after i input the username and password why that i should click the submit button twice in the log in content to redirect to logged in content?
like this: username obink password obink and enter
first log in is nothing happened but the username field and password field are empty the second log in with the blank fields of username and password is the time to redirect the log in content to the logged in content
is it my code is going wrong or what? i had trying to rebuild the css but there is nothing happened. And ow ya, i have users function page already, it is the page which is storing any function what i need
here is the headers content design more or less:
div logo
div search box
and div user log in or not like this
if (logged_in($user_data['user_id']) === false){
include 'login.php';
}
else{
include 'logged_in.php';
}
all is float left
and the php in the user functions
function logged_in(){
return (isset($_SESSION['user_id'])) ? true : false;
}
in my source.php page
if(logged_in() === true)
{$sid = $_SESSION['user_id'];
$user_data = user_data($_SESSION['user_id'], 'user_id', 'username', 'password', 'firstname', 'lastname', 'email');
}
renew the condition on my headers html on headers
<div id="header">
<div id="header-content">
<div id="logo">
<a href="index.php" style="text-decoration:none;">
logo</a>
</div>
<div id="searchbox">
<input type="text" placeholder="Search" size="50">
</div>
php on the middle of headers
if(empty($_SESSION['user_id'])){
include 'includes/widgets/login.php';
}
else{
include 'includes/widgets/loggedin.php';
}
closing div
</div>
</div>
sorry for my English