-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
154 lines (139 loc) · 4.7 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Spot-Sport</title>
<!-- Bootstrap core CSS -->
<link rel="shortcut icon" href="assets/favicon.ico">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/custom" rel="stylesheet">
<style type="text/css">
body {
padding-top: 12%;
padding-bottom: 40px;
background-color: #eee;
}
.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="text"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
</style>
</head>
<body>
<div class="container">
<?php
include "koneksi.php";
$qid = mysql_query('SELECT MAX(iduser) FROM user');
list($id) = mysql_fetch_row($qid);
$idbaru = $id + 1;
if( isset( $_REQUEST['submit2'] ) ){
$username = $_REQUEST['username'];
$nickname = $_REQUEST['nickname'];
$password = $_REQUEST['password'];
$sql = mysql_query("insert into user values('$idbaru','$username','$password','0','$nickname@konsumen')");
header('Location: ');
}
if( isset( $_REQUEST['submit'] ) ){
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$sql = mysql_query("SELECT iduser,username,admin,fullname FROM user WHERE username='$username' AND password='$password' ");
if( mysql_num_rows($sql) > 0 ){
list($iduser,$username,$admin,$fullname) = mysql_fetch_array($sql);
//session_start();
$_SESSION['iduser'] = $iduser;
$_SESSION['username'] = $username;
$_SESSION['admin'] = $admin;
$_SESSION['fullname'] = $fullname;
header("Location: ./admin.php");
die();
} else {
//$err = '<strong>ERROR!</strong> Username dan Password tidak ditemukan.';
//header('Location: ./?err='.urlencode($err));
$_SESSION['err'] = '<strong>ERROR!</strong> Username dan Password tidak ditemukan.';
header('Location: ./');
die();
}
} else {
?>
<div class="tab-content">
<div id="login" class="tab-pane fade in active">
<form class="form-signin" method="post" action="" role="form">
<?php
if(isset($_SESSION['err'])){
$err = $_SESSION['err'];
echo '<div class="alert alert-warning alert-message">'.$err.'</div>';
}
?>
<h2 align="center" class="form-signin-heading"><span class="glyphicon glyphicon-leaf"></span> Spot-Sport </h2>
<input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-info btn-block" type="submit" name="submit">Login</button>
<a data-toggle="tab" href='#register'><h5 align='right'><u><em>Buat akun baru</u></em> ?</h5></a>
</form>
</div>
<div id="register" class="tab-pane fade in">
<form class="form-signin" method="post" action="" role="form">
<?php
if(isset($_SESSION['err'])){
$err = $_SESSION['err'];
echo '<div class="alert alert-warning alert-message">'.$err.'</div>';
}
?>
<h2 align="center" class="form-signin-heading"><span class="glyphicon glyphicon-leaf"></span> Spot-Sport </h2>
<input type="text" name="username" class="form-control" placeholder="Username" required autofocus>
<input type="text" name="nickname" class="form-control" placeholder="Nickname" required>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-info btn-block" type="submit" name="submit2">Register</button>
<a data-toggle="tab" href="#login"><h5 align='left'><u><em>Sudah punya akun</u></em> ?</h5></a>
</form>
</div>
</div>
<?php
}
?>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript, Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">
$(".alert-message").alert().delay(1000).slideUp('slow');
</script>
</body>
</html>