/
signin.php
64 lines (57 loc) · 2.15 KB
/
signin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
session_start();
include('include/connection.inc.php');
//Check login
if(isset($_POST['user'])&&$_POST['user']!=NULL&&isset($_POST['pass'])&&$_POST['pass']!=NULL){
$iuser = $_POST['user'];
$ipass = $_POST['pass'];
$sql = 'SELECT * FROM `member` WHERE `m_user` = \''.$iuser.'\' AND `m_pass` = \''.$ipass.'\'';
$query = mysqli_query($objConnect,$sql);
$flag = (mysqli_num_rows($query)==1)?TRUE:FALSE;
//Save data to session
if($flag){
$_SESSION['login'] = TRUE;
$_SESSION['user'] = $iuser;
header("location:index.php");
}else{
$_SESSION['login'] = FALSE;
$_SESSION['user'] = NULL;
$alert_text = '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><strong>Login fail!</strong> Username or Password is incorrect.</div>';
}
}
include('include/header.inc.php');
showHeader('signin');
?>
<?php
//Aler login
if(isset($alert_text)){
echo $alert_text;
}
?>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title"><strong>Please sign in</strong></h3>
</div>
<div class="panel-body">
<form role="form" method="post">
<div class="form-group">
<input name="user" type="text" class="form-control" placeholder="Username" required autofocus>
</div>
<div class="form-group">
<input name="pass" type="password" class="form-control" placeholder="Password" required>
</div>
<div class="form-group col-md-offset-2">
<button class="btn btn-primary col-md-4" style="margin-left:14px;" type="submit">Sign in</button>
<a href="register.php" class="btn btn-warning col-md-4" style="margin-left:14px;">Register</a>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="alert alert-warning"><strong>Notice:</strong> If you did not create the account then you can not sell everything on system and the buyer cannot give the rate point for you.</div>
<?php
include('include/footer.inc.php');
?>