-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsearch.php
44 lines (42 loc) · 1.2 KB
/
search.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
<?php
//obtain user input
if (isset($_POST)) {
$input = sanitizeString($_POST['input']);
$input = trim($input);
$area = $_POST['list'];
}
//branch into 4 paths
switch ($area) {
case 'house_members':
$tokens = explode(' ', $input, 2); //split string on first space
$first_name = trim($tokens[0]);
$last_name = trim($tokens[1]);
//edge case handling
if ($input == 'C.A. Dutch Ruppersberger') {
$first_name = 'C.A. Dutch';
$last_name = 'Ruppersberger';
}
include_once "pages/house_member.php";
break;
case 'senate_members':
$tokens = explode(' ', $input, 2); //split string on first space
$first_name = trim($tokens[0]);
$last_name = trim($tokens[1]);
include_once "pages/senate_member.php";
break;
default:
break;
}
function sanitizeString($var) {
if (get_magic_quotes_gpc())
$var = stripslashes($var);
$var = strip_tags($var);
$var = htmlentities($var);
return $var;
}
function sanitizeMySQL($connection, $var) {
$var = $connection -> real_escape_string($var);
$var = sanitizeString($var);
return $var;
}
?>