-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
45 lines (36 loc) · 1.12 KB
/
insert.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
<?php
include_once('includes/connection.inc.php');
if(filter_var($_POST['regData']['email'], FILTER_VALIDATE_EMAIL)){
$email = $_POST['regData']['email'];
}else {
echo "Email is not valid " . $email;
}
if(filter_var($_POST['regData']['fname'], FILTER_SANITIZE_STRING)){
$fname = $_POST['regData']['fname'];
}else {
echo "First name input not allowed.";
}
if(filter_var($_POST['regData']['lname'], FILTER_SANITIZE_STRING)){
$lname = $_POST['regData']['lname'];
}else {
echo "Last name input not allowed.";
}
$passw = md5($_POST['regData']['passw']);
if(filter_var($_POST['regData']['use'], FILTER_VALIDATE_INT)){
$use = $_POST['regData']['use'];
}else {
echo "Use input not allowed.";
}
$query = "INSERT INTO user(`email`, `first_name`, `surname`, `password`, `use`) VALUES (?, ?, ?, ?, ?)";
if($instmt = $conn->prepare($query)) {
$instmt->bind_param("ssssi", $email, $fname, $lname, $passw, $use);
echo "Accepted";
}else{
echo "Denied";
/*echo "Error " . mysqli_error($conn);*/
}
$instmt->execute();
/*echo "New records created successfully.";*/
$instmt->close();
$conn->close();
?>