-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateEntry.php
More file actions
158 lines (117 loc) · 4.03 KB
/
updateEntry.php
File metadata and controls
158 lines (117 loc) · 4.03 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
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
153
154
155
156
157
158
<html>
<title>Update Entry</title>
<center>
<h2>Update Entry</h2>
<head>
<link rel='stylesheet' href='StyleSheet.css'>
</head>
</html>
<?php
session_start(); /*required for session data*/
unset($_SESSION['sqlQuery']); //resets session variable
$conn = connectToSql();
?>
<?php
echo "<table>";
echo "<td valign='top'>";
echo "<center>
<div class='boxed'>
<form action='update_data.php' method='post'>
<label id='entryNumber'><b>Entry Number:<font color='red'>*</font></b></label><br/>
<input type='text' name='E_ID' required><br/>
<label id='first'>Family ID:</label><br/>
<input type='text' name='F_ID'><br/>
<label id='first'>House Number:</label><br/>
<input type='text' name='House_number'><br/>
<label id='first'>Street Address:</label><br/>
<input type='text' name='Street_Addr'><br/>
<label id='first'>Last Name:</label><br/>
<input type='text' name='Last_name'><br/>
<label id='first'>First Name:</label><br/>
<input type='text' name='First_Name'><br/>
<label id='first'>Age:</label><br/>
<select name='Age'>
<option value=''>Select If Needed..</option>
<option value='Adult'>Adult</option>
<option value='Youth'>Youth</option>
<option value='Child'>Child</option>
<option value='Toddler'>Toddler</option>
</select><br/>
<label id='first'>Visitation Info:</label><br/>
<textarea wrap='hard' type='text' name='Visitation_Info' style='height:100px;width:350px'></textarea><br/>
<label id='first'>Next Visitation:</label><br/>
<input type='date' name='Next_Visitation'><br/>
<label id='first'>Last Visitation:</label><br/>
<input type='date' name='Last_Visitation'><br/>
<label id='first'>Phone Number:</label><br/>
<input type='tel' name='Phone_Number'><br/>
<label id='Status_'>Status:</label><br/>
<select name='Status_'>
<option value=''>Select If Needed..</option>
<option value='Church'>Church</option>
<option value='Prospect'>Prospect</option>
<option value='Moved'>Moved</option>
<option value='Deceased'>Deceased</option>
<option value='Unwanted'>Unwanted</option>
</select><br/>
<button type='submit' name='save'>Save</button>
</form>
<form action='database.php' method='post'>
<button type='Back' name='back' onClick='location.href='database.php'>Back</button>
</form>
</div>";
echo "</td>";
echo "<td valign='top'>";
/* **************************Show data in table *********************************/
$result = mysqli_query($conn,"Select * from Families");
$all_property = array(); //declare an array for saving property
//showing property
echo "<table class='data-table' border='1'>
<tr class='data-heading'>"; //initialize table tag
while ($property = mysqli_fetch_field($result)) {
echo '<td><b>' . $property->name . '</td></b>'; //get field name for header
array_push($all_property, $property->name); //save those to array
}
echo '</tr>'; //end tr tag
//showing all data
while ($row = mysqli_fetch_array($result)) {
echo "<tr>";
foreach ($all_property as $item) {
echo '<td>' . nl2br($row[$item]) . '</td>'; //get items using property value
}
echo '</tr>';
}
echo "</table>";
$conn->close();
echo "</td></table>";
?>
<?php
$conn->close();
?>
<?php
function connectToSql()
{
$host = "localhost";
$db_name = "fbca_visitation";
$user = $_POST["Username"];
$pass = $_POST["Password"];
if($user == "" && $pass == ""){
$user = $_SESSION["user"];
$pass = $_SESSION["pass"];
}
$_SESSION["pass"] = $pass;
$_SESSION["user"] = $user;
$conn = mysqli_connect($host, $user, $pass, $db_name);
//test if connection failed
if(mysqli_connect_errno())
{
echo '<form><button type="button" value="Return to previous page" onClick="javascript:history.go(-1)">Return to previous page</button></form>';
die("connection failed: "
. mysqli_connect_error()
. " (" . mysqli_connect_errno()
. ")"
);
}
return $conn;
}
?>