-
Notifications
You must be signed in to change notification settings - Fork 1
/
addRecord.php
73 lines (59 loc) · 1.73 KB
/
addRecord.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
<html>
<head>
<title>Luna</title>
</head>
<body>
<?php
if(isset($_POST['submit'])) {
$data_missing = array();
if(empty($_POST['name'])) {
$data_missing[] = "Name";
} else {
$arr_name = trim($_POST['name']);
}
if(empty($_POST['college'])) {
$data_missing[] = "College";
} else {
$col = trim($_POST['college']);
}
if(empty($_POST['email'])) {
$data_missing[] = "Email";
} else {
$mail = trim($_POST['email']);
}
if(empty($_POST['events'])) {
$data_missing[] = "Events";
} else {
$event = trim($_POST['events']);
}
if(empty($_POST['status'])) {
$data_missing[] = "Status";
} else {
$payment = trim($_POST['status']);
}
if(empty($_POST['password'])) {
$data_missing[] = "Password";
} else {
$pass = trim($_POST['Password']);
}
if(empty($data_missing)) {
require_once("config.php");
$query = "INSERT INTO registrations(name, college, email, events, status) VALUES (?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($dbc, $query);
mysqli_stmt_bind_param($stmt, "sssss", $arr_name, $col, $mail, $event, $payment);
mysqli_stmt_execute($stmt);
$affected_rows = mysqli_stmt_affected_rows($stmt);
if($affected_rows==1) {
echo 'Record added';
}
else {
echo "Error <br/>";
mysqli_error($dbc);
}
mysqli_stmt_close($stmt);
mysqli_close($dbc);
}
}
?>
</body>
</html>