-
Notifications
You must be signed in to change notification settings - Fork 0
/
eaoreg.php
48 lines (44 loc) · 1.7 KB
/
eaoreg.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
<?php
include ('includes/connec.inc.php');
if (isset($_POST['firstname'])&&isset($_POST['lastname'])&&isset($_POST['dept'])&&isset($_POST['staffno'])&&isset($_POST['email'])&&isset($_POST['password'])){
$firstname = mysqli_escape_string($conn, $_POST['firstname']);
$lastname = mysqli_escape_string($conn, $_POST['lastname']);
$dept = mysqli_escape_string($conn, $_POST['dept']);
$staffno = mysqli_escape_string($conn, $_POST['staffno']);
$email = mysqli_escape_string($conn, $_POST['email']);
$password_1 = mysqli_escape_string($conn, $_POST['password']);
$password = md5($password_1);
if (!empty($firstname) || !empty($password) || !empty($lastname) || !empty($email) ||
!empty($dept) || !empty($staffno)) {
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT email From eaouser Where email = ? Limit 1";
$INSERT = "INSERT Into eaouser (firstname,lastname, dept, email, password, staffno) values(?, ?, ?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("sssssi", $firstname, $lastname, $dept, $email, $password, $staffno);
$stmt->execute();
header("location: register2.php?msg=run");
//echo "New record inserted sucessfully";
} else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();
}
}
else {
echo "All field are required";
die();
}
}
?>