Repository navigation
Expand file tree
/
Copy pathselect.php
More file actions
74 lines (53 loc) · 2.31 KB
/
Copy pathselect.php
File metadata and controls
74 lines (53 loc) · 2.31 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
<?php
require_once("./included_functions.php");
require_once("session.php");
new_header("Your Volunteers", "");
$mysqli = db_connection();
if (($output = message()) !== null) {
echo $output;
}
echo "<h3>Check List</h3>";
echo "<div class='row'>";
echo "<label for='left-label' class='left inline'>";
if (isset($_POST["submit"])) {
if( (isset($_POST["fname"]) && $_POST["fname"] !== "") && (isset($_POST["lname"]) && $_POST["lname"] !== "")){
$first = $mysqli->real_escape_string(trim($_POST['fname']));
$last = $mysqli->real_escape_string(trim($_POST['lname']));
$query = "SELECT Host.first_name As 'Host First Name', Host.last_name AS 'Host Last Name', ";
$query.="GROUP_CONCAT(volunteers.first_name ORDER BY volunteers.first_name) AS 'First Name', ";
$query.= "GROUP_CONCAT(volunteers.last_name ORDER BY volunteers.first_name) AS 'Last Name' FROM Host ";
$query.= "JOIN Projects ON Projects.Host=Host.host_number ";
$query.= "JOIN volunteers ON Projects.Project_Number=volunteers.project ";
$query.= "WHERE Host.first_name='".$first."' AND Host.last_name = '".$last."' GROUP BY Host.first_name";
echo $query;
$result = $mysqli->query($query);
if($result) {
$_SESSION["message"] = $_POST["fname"]." ".$_POST["lname"]."'s Volunteers";
header("Location: view.php");
exit;
}
else {
$_SESSION["message"] = "Error! Could not change ".$_POST["fname"]." ".$_POST["lname"];
}
}
else {
$_SESSION["message"] = "Unable to add person. Fill in all information!";
header("Location: view.php");
exit;
}
}
else {
echo "<form method='POST' action='select.php'>";
echo "First Name:<input type='text' name='fname' value='' />";
echo "Last Name:<input type='text' name='lname' value='' />";
echo "<input type='submit' name='submit' class='button tiny round' value='Find Volunteers'>";
echo "</form>";
// Part b. Include <input> tags for each of the attributes in person:
// First Name, Last Name, Birthdate, Birth City, Birth State, Region
//////////////////////////////////////////////////////////////////////////////////////////////////
}
echo "</label>";
echo "</div>";
echo "<br /><p>«:<a href='select.php'>Back to Main Page</a>";
?>
<?php new_footer("Who's Who", $mysqli); ?>