-
Notifications
You must be signed in to change notification settings - Fork 0
/
addCustomer.php
108 lines (95 loc) · 3.15 KB
/
addCustomer.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require("mysql.php");
$mysqli = MySql::getConnection();
$user_message = "";
if(isset($_POST['submit'])){
$name = $_POST['name'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$city = $_POST['city'];
$email = $_POST['email'];
$cardNumber = $_POST['cardNumber'];
$insert = $mysqli->query("INSERT INTO People (`Name`, `Phone`, `Address`, `City`) VALUES ('$name', '$phone', '$address', '$city')");
if(!$insert){
trigger_error("There was an error. Could not insert into the database. Error: $mysqli->error");
}
else {
$customer_id = $mysqli->insert_id;
$insert = $mysqli->query("INSERT INTO Customers (`ID`, `Email`, `CardNumber`) VALUES ('$customer_id', '$email', '$cardNumber')");
if(!$insert){
trigger_error("There was an error. Could not insert into the database. Error: $mysqli->error");
}
else {
$user_message = "Thank you. Your new customer has successfully been added.";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>EECS 341</title>
<link href="bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Welcome to the Coffee Shop. <small>Add a New Customer.</small></h1>
</div>
<?php
if($user_message != ""){
echo '<div class="alert alert-success" role="alert">'.$user_message.'</div>';
}
?>
<p><a href="http://eecs341.pollack.tech">RETURN TO HOME</a></p>
<form method="post">
<div class="row">
<div class="col-md-4">
<input type="text" name="name" class="form-control" placeholder="Name"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<input type="text" name="address" class="form-control" placeholder="Address"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<input type="text" name="city" class="form-control" placeholder="City"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<input type="text" name="phone" class="form-control" placeholder="Phone"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<input type="text" name="email" class="form-control" placeholder="Email"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<input type="text" name="cardNumber" class="form-control" placeholder="Card Number"/>
</div>
</div>
<div class="row">
<div class="col-md-4">
<button type="submit" class="btn btn-default" name="submit" value="submit">Submit</button>
</div>
</div>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="bootstrap-3.3.6/js/bootstrap.min.js"></script>
</body>
</html>