-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateModel.php
More file actions
90 lines (82 loc) · 3.09 KB
/
updateModel.php
File metadata and controls
90 lines (82 loc) · 3.09 KB
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
<?php
include_once 'header.php';
//Load variables with data...
//Basic variables...
if ($_POST['hw_type']){ $hw_type = $_POST['hw_type'];}
if ($_POST['manufacturer']){ $manufacturer = $_POST['manufacturer'];}
if ($_POST['model']){ $model = $_POST['model'];}
if ($_POST['type']){ $type = $_POST['type'];}
if ($_POST['action']){ $action = $_POST['action'];}
//Computer only variables...
if ($_POST['processor']){ $processor = $_POST['processor'];}
if ($_POST['processor_speed']){ $processor_speed = $_POST['processor_speed'];}
if ($_POST['memory']){ $memory = $_POST['memory'];}
if ($_POST['hard_drive_size']){ $hard_drive_size = $_POST['hard_drive_size'];}
if ($_POST['original_os']){ $original_os = $_POST['original_os'];}
//Monitor only variables...
if ($_POST['size']){ $size = $_POST['size'];}
//Process new inventory request...
if ($action == 'save')
{
switch ($hw_type) {
case 'computer':
//Build SQL statement to save a computer request...
$sql_statement = "INSERT INTO computer_model (manuf, model, processor, processor_speed, memory, HD_size, original_OS) VALUES ('" . $manufacturer . "', '" . $model . "', '" . $processor . "', '" . $processor_speed . "', '" . $memory . "', '" . $hard_drive_size . "', '" . $original_os . "');";
break;
case 'scanner':
//Build SQL statement to save a scanner request...
$sql_statement = "INSERT INTO scanner_model (manuf, model) VALUES ('" . $manufacturer . "', '" . $model . "');";
break;
case 'monitor':
//Build SQL statement to save a monitor request...
$sql_statement = "INSERT INTO monitor_model (manuf, model, type, size) VALUES ('" . $manufacturer . "', '" . $model . "', '" . $type . "', '" . $size . "');";
break;
case 'projector':
//Build SQL statement to save a projector request...
$sql_statement = "INSERT INTO projector_model (manuf, model) VALUES ('" . $manufacturer . "', '" . $model . "');";
break;
default:
//Build SQL statement to save a printer request...
$sql_statement = "INSERT INTO printer_model (manuf, model, type) VALUES ('" . $manufacturer . "', '" . $model . "', '" . $type . "');";
break;
}
//Debugging...
if ($debugging)
{
print 'DEBUG: ' . $sql_statement . '<br />';
}
//Execute the built query string
$execute = mysql_query($sql_statement) or $error_message = "There was an error in your query " . mysql_error();
}
if (!$execute)
{
?>
<div data-role="dialog" class="type-interior">
<div data-role="header" data-theme="a">
<h1>Error Updating</h1>
<a href="#" data-icon="home" data-iconpos="notext" data-direction="reverse" onclick="history.go(-1)">Back</a>
</div><!-- /header -->
<br />
<div data-role="content">
<?php print $error_message?>
</div>
</div>
<?php
} else {
?>
<div data-role="dialog" class="type-interior">
<div data-role="header" data-theme="a">
<h1>Item Updated!!</h1>
</div><!-- /header -->
<br />
<div data-role="content">
<meta http-equiv="REFRESH" content="3; url=index.php">
Your Inventory Item has been updated successfully. <?php print $nextid ?><br />
</div>
</div>
<?php
}
include_once 'common/dbclose.inc.php';
include_once 'footer.php';
include_once 'common/end.inc.php';
?>