forked from kokonior/PHP-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarc3
53 lines (51 loc) · 1.45 KB
/
marc3
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
<?php
/**
* Absensi Siswa Prakerin
* codinger-mini.blogpsot.com
* fb.me/rizal.ofdraw
*/
include '../lib/db/dbconfig.php';
if (isset($_POST['add_pbXia1Zasww12Q'])) {
$query = $conn->query("SELECT*FROM user");
$id = $query->num_rows+1;
$email = mysqli_real_escape_string($conn, $_POST['email']);
$pwd = mysqli_real_escape_string($conn, sha1($_POST['pwd']));
$nama = mysqli_real_escape_string($conn, $_POST['nama']);
$level = "pb";
$sql_user = "INSERT INTO user (id_user,
email_user,
pwd_user,
level_user) VALUES(?,
?,
?,
?)";
$sql_detail = "INSERT INTO detail_pb (id_user,
name_user) VALUES(?,
?)";
$cek =$conn->query("SELECT*FROM user WHERE email_user='$email'")->num_rows;
if ($email==="" || $pwd==="" || $nama ==="") {
header("location:../root/add_pb.php?st=4");
} else {
if ($cek==0) {
if ($statement = $conn->prepare($sql_user) AND $statement1 = $conn -> prepare($sql_detail)) {
$statement->bind_param(
"isss", $id, $email, $pwd, $level
);
$statement1->bind_param(
"is", $id, $nama
);
if ($statement->execute() && $statement1->execute()) {
header("location:../root/add_pb.php?st=1");
} else {
header("location:../root/add_pb.php?st=2");
}
}
} else {
header("location:../root/add_pb.php?st=3");
}
}
$conn->close();
} else {
echo "<script>window.alert('Waaahh.. Bandel ya !! ');window.location=('../home');</script>";
}
?>