-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_customer.php
46 lines (41 loc) · 1.74 KB
/
process_customer.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
<?php
require_once('./dao/customerDAO.php');
if(isset($_GET['action'])){
if($_GET['action'] == "edit"){
if(isset($_POST['customerId']) &&
isset($_POST['customerName']) &&
isset($_POST['emailAddress']) &&
isset($_POST['phoneNumber'])){
if(is_numeric($_POST['customerId']) &&
$_POST['customerName'] != "" &&
$_POST['emailAddress'] != "" &&
$_POST['phoneNumber'] != ""){
$customerDAO = new customerDAO();
$result = $customerDAO->editCustomer($_POST['customerId'],
$_POST['customerName'], $_POST['emailAddress'], $_POST['phoneNumber']);
if($result > 0){
header('Location:edit_customer.php?recordsUpdated='.$result.'&customerId=' . $_POST['customerId']);
} else {
header('Location:edit_customer.php?customerId=' . $_POST['customerId']);
}
} else {
header('Location:edit_customer.php?missingFields=true&customerId=' . $_POST['customerId']);
}
} else {
header('Location:edit_customer.php?error=true&customerId=' . $_POST['customerId']);
}
}
if($_GET['action'] == "delete"){
if(isset($_GET['customerId']) && is_numeric($_GET['customerId'])){
$customerDAO = new customerDAO();
$success = $customerDAO->deleteCustomer($_GET['customerId']);
echo $success;
if($success){
header('Location:mailing_list.php?deleted=true');
} else {
header('Location:mailing_list.php?deleted=false');
}
}
}
}
?>