-
Notifications
You must be signed in to change notification settings - Fork 0
/
Modify_upc_update_data_services.php
executable file
·152 lines (116 loc) · 4.12 KB
/
Modify_upc_update_data_services.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php require_once("includes/validation_functions.php"); ?>
<?php require_once("includes/header_update.php"); ?>
<?php
if(isset($_POST["insertDataSubmit"])){
// validations
$required_fields = array("Feeder_Name", "Vault_Name","Vault_Section");
validate_presences($required_fields);
if(empty($errors)){
$query1 = "select COLUMN_NAME from information_schema.columns where TABLE_NAME = 'elec_upc_services'";
$result1 = mysqli_query($connection,$query1);
echo '<table style="width:80%" CLASS="dispTable">';
while($data = mysqli_fetch_assoc($result1))
{
echo '<th>'.$data['COLUMN_NAME'].'</th>';
}
echo '</table>';
$varFeederName = mysql_prep($_POST['Feeder_Name']);
$varVaultName = mysql_prep($_POST['Vault_Name']);
$varVaultSection = mysql_prep($_POST['Vault_Section']);
$query2 = "INSERT INTO elec_upc_services(Feeder_Name, Vault_Name, Vault_Section) VALUES ( '{$varFeederName}','{$varVaultName}','{$varVaultSection}')";
$result2 = mysqli_query($connection,$query2);
//$result2 = mysqli_query("select COLUMN_NAME from information_schema.columns where TABLE_NAME = 'elec_UPC_SERVICES'");
if($result2){
$_SESSION["message"] = "Data Inserted";
}
else{
$_SESSION["message"] = "Data Insertion Failed";
}
}
}
if(isset($_POST['updateDataSubmit']))
{
$required_fields = array("serviceType", "vaultType","vaultSectionType");
validate_presences($required_fields);
if(empty($errors)){
$query3 = "UPDATE elec_upc_services SET Vault_Name=". {$varVaultName} .", Vault_Section=". {$varVaultSection}. " WHERE Feeder_Name=".{$varFeederName} ." LIMIT 1";
$result3 = mysqli_query($connection,$query3);
if($result3){
$_SESSION["message"] = "Data Updated";
}
else{
$_SESSION["message"] = "Data Updation Failed";
}
}
}
?>
<div id="contentsTable">
<?php echo message(); ?>
<?php echo form_errors($errors); ?>
<form action="Modify_upc_update_data_services.php" method="post">
<table style="width:80%" CLASS="dispTable">
<td><input type="text" name="Feeder_Name" style="width: 99%;"></td>
<td><input type="text" name="Vault_Name" style="width: 99%;"></td>
<td><input type="text" name="Vault_Section" style="width: 99%;"></td>
</table>
<input type="submit" name="insertDataSubmit" value="InsertData">
</form>
<br><br>
<form action="Modify_upc_update_data_services.php" method="post">
<table style="width:80%" CLASS="dispTable">
<td>
<select name="serviceType">
<?php
$result = mysqli_query("select distinct Feeder_Name from elec_upc_services");
echo'<option value="Select...">Select...</option>';
while($data = mysql_fetch_array($result))
{
echo'<option value="'.$data[Feeder_Name].'">'.$data[Feeder_Name].'</option>';
}
?>
</select>
</td>
<td>
<select name="vaultType">
<?php
$result = mysql_query("select distinct Vault_Name from elec_UPC_SERVICES");
echo'<option value="Select...">Select...</option>';
while($data = mysql_fetch_array($result))
{
echo'<option value="'.$data[Vault_Name].'">'.$data[Vault_Name].'</option>';
}
?>
</select>
</td>
<td>
<select name="vaultSectionType">
<?php
$result = mysql_query("select distinct Vault_Section from elec_UPC_SERVICES");
echo'<option value="Select...">Select...</option>';
while($data = mysql_fetch_array($result))
{
echo'<option value="'.$data[Vault_Section].'">'.$data[Vault_Section].'</option>';
}
?>
</select>
</td>
</table>
<input type="submit" name="updateDataSubmit" value="UpdateData">
</form>
<?php include("includes/footer.php"); ?>
<!--<div id="footer">
<span class="divider"></span>
<div class="area">
<div id="connect">
<a href="" target="_blank" class="googleplus"></a> <a href="" target="_blank" class="mail"></a> <a href="" target="_blank" class="facebook"></a> <a href="" target="_blank" class="twitter"></a>
</div>
<p>
� USC FMS - Engineering Services/Electrical. All Rights Reserved.
</p>
</div>
</div>
</body>
</html>-->