-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateCustomerForm.php
More file actions
37 lines (34 loc) · 939 Bytes
/
UpdateCustomerForm.php
File metadata and controls
37 lines (34 loc) · 939 Bytes
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
<html>
<head>
<meta http-equiv="refresh" content="0; url=Customers.php" />
</head>
<body>
<?php
include "db.php";
// get content from form
$id = $_POST["id"];
$firstname = $_POST["firstname"];
$surname = $_POST["surname"];
$address = $_POST["address"];
$city = $_POST["city"];
$postcode = $_POST["postcode"];
$email = $_POST["email"];
$phonenumber = $_POST["phonenumber"];
// SQL Insert using variable names
$sql = "SELECT customerID FROM customer WHERE customerID='$id'";
$result = mysql_query($sql);
if(mysql_num_rows($result) <1){
echo "There is no customer with such ID";
}
else{
if($phonenumber==null)
{
$phonenumber = 0;
}
mysql_query("Update customer SET cFname = '$firstname', cSurname = '$surname', cAddress = '$address', cCity = '$city', cPostcode = '$postcode', cEmail = '$email', cPhoneNumber = '$phonenumber'
WHERE customerID = '$id'", $db);
echo "A customer was successfully updated <br>";
}
?>
</body>
</html>