67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
error_reporting( 1 );
|
|
ini_set( "display_errors", 1 );
|
|
?>
|
|
<?php
|
|
SESSION_START();
|
|
include('./header.php');
|
|
$loginError = '';
|
|
if (!empty($_POST['username']) && !empty($_POST['pwd'])) {
|
|
include ('Chat.php');
|
|
$chat = new Chat();
|
|
$user = $chat->loginUsers($_POST['username'], $_POST['pwd']);
|
|
|
|
//var_Dump($user);
|
|
|
|
if(!empty($user)) {
|
|
$_SESSION['username'] = $user[0]['username'];
|
|
$_SESSION['userid'] = $user[0]['userid'];
|
|
$chat->updateUserOnline($user[0]['userid'], 1);
|
|
$lastInsertId = $chat->insertUserLoginDetails($user[0]['userid']);
|
|
$_SESSION['login_details_id'] = $lastInsertId;
|
|
header("Location:index.php");
|
|
} else {
|
|
$loginError = "Invalid username or password!";
|
|
}
|
|
}
|
|
|
|
?>
|
|
<title>Home</title>
|
|
<?php include('./container.php');?>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<h4>Chat Login:</h4>
|
|
<form method="post">
|
|
<div class="form-group">
|
|
<?php if ($loginError ) { ?>
|
|
<div class="alert alert-warning"><?php echo $loginError; ?></div>
|
|
<?php } ?>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="username">User:</label>
|
|
<select type="username" class="form-control input-lg" name="username" required>
|
|
<option value="1">이성노</option>>
|
|
<option value="2">이윤영</option>>
|
|
<option value="3">이윤서</option>>
|
|
<option value="4">이은지</option>>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="pwd">Password:</label>
|
|
<input type="password" class="form-control input-lg" name="pwd" required>
|
|
</div>
|
|
<button type="submit" name="login" class="btn btn-info btn-lg">Login</button>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<?php include('./footer.php');?>
|
|
|
|
|
|
|
|
|
|
|
|
|