forked from udsaxman/Sapphirev2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processItemCategories.php
48 lines (38 loc) · 1.15 KB
/
processItemCategories.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
<?php
include 'connection.php';
//Note to self, figure out userinput validation so people don't submit sql strings for update values
foreach ($_POST['catupdate'] as $cat){
if(isset($cat['id']) && isset($cat['order'])&& isset($cat['tax'])){
$sql = "CALL sp_UpdateItemCategory(".$cat['id'].",". $cat['order'].",". $cat['tax'].",".(isset($cat['override'])? 1 : 0)." )";
$result = $mysqli->query($sql);
if (!$result) {
Fail();
}
$result->close();
}
}
foreach ($_POST['newCat'] as $newcat){
print_r($newcat);
echo "</br>";
if(isset($newcat['name']) && isset($newcat['tax'])&& isset($newcat['order'])){
//create new category
$sql = "CALL sp_AddNewItemCategory('".$newcat['name']."', ".$newcat['order'].", ".$newcat['tax'].", ".(isset($newcat['override'])? 1 : 0).")";
$result = $mysqli->query($sql);
if (!$result) {
Fail();
}
$result->close();
}
}
$mysqli->close();
Success();
function Fail()
{
header('Location: ./TDSInError.php');
}
function Success()
{
header('Location: ./TDSInItemCategories.php');
//echo "Test";
}
?>