-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentryInput.php
155 lines (118 loc) · 3.96 KB
/
entryInput.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
153
154
155
<html>
<title>Entry Input</title>
<center>
<h2>Input 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><td>";
echo "<center>
<div class='boxed'>
<form action='insert_data.php' method='post'>
<label id='F_ID'>Family ID:</label><br/>
<input type='text' name='F_ID'><br/>
<label id='House'>House Number:</label><br/>
<input type='text' name='House'><br/>
<label id='Street_Addr'>Street Address:</label><br/>
<input type='text' name='Street_Addr'><br/>
<label id='Last_Name'>Last Name:</label><br/>
<input type='text' name='Last_name'><br/>
<label id='First_Name'>First Name:</label><br/>
<input type='text' name='First_Name'><br/>
<label id='Age'>Age:</label><br/>
<select name='Age'>
<option value=''>Select One..</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='Visitation_Information_and_Description'>Visitation Info:</label><br/>
<textarea wrap='hard' type='text' name='Visitation_Info' style='height:100px;width:350px'></textarea><br/>
<table><tr>
<td>
<label id='Next_Visitation'>Next Visitation:</label><br/>
<input type='date' name='Next_Visitation'><br/>
</td><td>
<label id='Last_Visitation'>Last Visitation:</label><br/>
<input type='date' name='Last_Visitation'><br/>
</td>
</tr></table>
<label id='Phone_Number'>Phone Number:</label><br/>
<input type='tel' name='Phone_Number'><br/>
<label id='Status_'>Status:</label><br/>
<select name='Status_'>
<option value=''>Select One..</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'>";
$result = mysqli_query($conn,"Select F_ID, House, Street_Addr, Last_Name from Families group by F_ID, House, Street_Addr, Last_Name");
$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;
}
?>