-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.php
86 lines (54 loc) · 2.18 KB
/
add.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
74
75
76
77
78
79
80
81
82
83
84
<?php
include_once 'header.php';
include_once 'includes/dbh.inc.php';
include_once 'includes/functions.inc.php';
if(isset($_POST['add'])){
$fname = $_POST['fname'];
$mname = $_POST['mname'];
$lname = $_POST['lname'];
$province = $_POST['province'];
$district = $_POST['district'];
$city = $_POST['city'];
$chowk = $_POST['chowk'];
$street = $_POST['street'];
$code = $_POST['code'];
$phone = $_POST['phone'];
$email = $_POST['email'];
if(emptyFields($fname , $mname , $lname , $province , $district , $city , $chowk ,
$street , $code ,$phone , $email)){
header("location: add.php?error=emptyFields");
exit();
}
$sql = "INSERT INTO form(First_Name, Middle_Name , Last_Name, Province ,District ,City
, Chowk ,Street_Name , Country_Code , Phone_Number ,Email) VALUES (? , ? ,? , ? ,? , ? ,? , ? ,? , ?,? )";
$stmt = mysqli_stmt_init($connection);
if(!mysqli_stmt_prepare($stmt , $sql)){
header("location: index.php?error=stmtFailed");
exit();
}
mysqli_stmt_bind_param($stmt , "ssssssssiss" , $fname , $mname , $lname , $province , $district , $city , $chowk ,
$street , $code , $phone , $email);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location: add.php?error=none");
}
include_once 'table.php';
?>
<?php
$Message = $_GET['error'];
if($Message == "emptyFields"){ ?>
<h4 style="text-align:center; color:red; padding-top:10px; opacity:0.6;"> FAILED TO ADD! </h4>
<h4 style="text-align:center; color:red; padding-top:10px; opacity:0.6;"> FILL OUT THE FORM COMPLETELY </h4>
<?php }
else if($Message == "emptyFieldsCannotUpdate"){ ?>
<br><br>
<h2 style="text-align:center; color:red; padding-top:10px; opacity:0.6;"> FAILED TO Update! </h2>
<?php }
else if($Message == "SuccessDeletion"){ ?>
<h2 style="text-align:center; color:red; padding-top:10px; opacity:0.6;"> Successfully Deleted! </h2>
<?php }
include_once 'form-part.php';
?>
<?php
include_once 'footer.php';
?>