-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateVendor.php
45 lines (39 loc) · 1.23 KB
/
updateVendor.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 'functions.php';
// In this file we will update the values in the database.
if(!empty($_POST["vid"]))
{
$vid = $_POST['vid'];
updateValue("VendorName", $_POST["venderName"], $vid);
updateValue("Address", $_POST["address"], $vid);
updateValue("City", $_POST["city"], $vid);
updateValue("State", $_POST["state"], $vid);
updateValue("Country", $_POST["country"], $vid);
updateValue("Zip", $_POST["zip"], $vid);
updateValue("UCRAccount", $_POST["UCRAccID"], $vid);
updateValue("POC", $_POST["contact"], $vid);
updateValue("Phone", $_POST["phone"], $vid);
updateValue("Fax", $_POST["fax"], $vid);
updateValue("Website", $_POST["website"], $vid);
}
// Redirect to venders.php
header( 'Location: ./vender.php' ) ;
// Updates a single value.
function updateValue($valueName, $newValue, $valueID)
{
// Prevents writting an empty value to the table.
if(empty($valueName) OR empty($newValue) OR empty($valueID))
return;
$conn = connectTODB();
$sql = "UPDATE ListOfVendors SET ".$valueName."='".$newValue."' WHERE VID=".$valueID;
if ($conn->query($sql) === TRUE)
{
echo $valueName."updated successfully";
}
else
{
echo "Error updating record: " . $conn->error . "<br>";
}
$conn->close();
}
?>