-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdaftar-admin.php
More file actions
167 lines (133 loc) · 6.46 KB
/
daftar-admin.php
File metadata and controls
167 lines (133 loc) · 6.46 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
include 'koneksi/koneksi.php';
$redirect = "";
//check if button next is clicked
if(isset($_POST['submit'])){
//set all name attr and value to created variable
foreach ($_POST as $key => $val) {
${$key} = $val;
}
$query = "SELECT email FROM akun WHERE email='$email'";
$exac = mysqli_query($conn, $query);
if ($exac) {
$email_count = mysqli_num_rows($exac);
if ($email_count > 0) {
echo '<script>alert("Email sudah digunakan, silahkan gunakan email lain..")</script>';
}else{
$cost = 10;
$hash = password_hash($password,PASSWORD_BCRYPT,["cost" => $cost]);
$queryInsert = "INSERT INTO akun VALUES(null, '$email', '$hash', '$nama', 0, null)";
$execQueryInsert = mysqli_query($conn,$queryInsert);
if ($execQueryInsert) {
echo 'bisa';
//check if session is not empty, then redirect to daftar_data_orangtua.php
echo '<script>alert("berhasil melakukan pendaftaran")</script>';
echo "<script> window.location='login.php'</script>";
}else{
echo 'ada';
echo mysqli_error($conn);
}
}
}else{
echo mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png" />
<link rel="icon" type="image/png" href="../assets/img/favicon.png" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Registrasi Admin</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<!-- Material Dashboard CSS -->
<link href="assets/css/material-dashboard.css?v=1.2.0" rel="stylesheet" />
<!-- CSS for Demo Purpose, don't include it in your project -->
<link href="assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and icons -->
<link href="assets/css/font-awesome.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300|Material+Icons' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="assets/css/main.css">
<script src="assets/js/jquery-3.2.1.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-8 col-lg-10 col-lg-offset-1">
<div class="card" style="margin-top: 50px">
<div class="card-header" data-background-color="blue">
<h4 class="title">Data Admin</h4>
<p class="category">Isi Form Registrasi admin dengan benar, akan digunakan untuk login sebagai Admin</p>
</div>
<div class="card-content">
<form method="post" action="">
<div class="row">
<div class="col-md-12">
<div class="form-group label-floating">
<label class="control-label">Email</label>
<input type="email" class="form-control" name="email" required autofocus>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group label-floating">
<label class="control-label">Nama Admin</label>
<input type="text" class="form-control" name="nama" required autofocus>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group label-floating">
<label class="control-label">Password</label>
<input type="password" class="form-control" id="pass" name="password" required>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group label-floating">
<label class="control-label">Konfirmasi Password</label>
<input type="password" class="form-control" id="kpass" name="konfirmasi_password" required>
<font id="err" color="red">Konfirmasi Password tidak sama dengan password</font>
</div>
</div>
</div>
<button type="submit" id="btnsb" name="submit" class="btn btn-primary pull-right">Daftar <i class="fa fa-arrow-right"></i></button>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function() {
$err = $("#err");
$btn = $("#btnsb");
$err.hide();
$(':input[type="submit"]').prop('disabled', true);
$("#kpass").on("change paste keyup",function(event) {
/* Act on the event */
event.preventDefault();
var pass = $("#pass").val();
var dpass = $("#kpass").val();
if (pass != dpass) {
$err.show();
$(':input[type="submit"]').prop('disabled', true);
}else{
$(':input[type="submit"]').prop('disabled', false);
$err.hide();
}
});
});
</script>