-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.3
More file actions
76 lines (66 loc) · 2.31 KB
/
index.3
File metadata and controls
76 lines (66 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
75
76
<?php
/**
*index.php
*CS50 2014 Final
*
*Jake Morrissey
*jakemorrissey@college.harvard.edu
*
*main page, displays portfolio and links
*/
// configuration
require("../includes/config.php");
if($_SERVER["REQUEST_METHOD"] == "GET")
{
$rows1 = query("SELECT name FROM states WHERE 1");
$positions = [];
foreach($rows1 as $row1)
{
$positions[] = [
"name" => $row1["name"]
];
}
render("template2.php", ["positions" => $positions, "title" => "Compare"]);
}
else if($_SERVER["REQUEST_METHOD"] == "POST")
{
$name = $_POST["nameselect"];
$name2 = $_POST["nameselect2"];
$ipopulation = $_POST["ipopulation"];
$iarea = $_POST["iarea"];
$itemp = $_POST["itemp"];
$opopulation = $_POST["opopulation"];
$oarea = $_POST["oarea"];
$otemp = $_POST["otemp"];
if ($ipopulation < 0 || $ipopulation > 10)
{
apologize("Make sure your population importance is between 0 and 10.");
}
else if ($iarea < 0 || $iarea > 10)
{
apologize("Make sure your area importance is between 0 and 10.");
}
else if ($itemp < 0 || $itemp > 10)
{
apologize("Make sure your average temperature importance is between 0 and 10.");
}
if (preg_match("/^\d+$/", $ipopulation) != true || preg_match("/^\d+$/", $iarea) != true || preg_match("/^\d+$/", $iarea) != true)
{
apologize("All importance numbers must be integers.");
}
if (empty($name) || empty($name2))
{
apologize("Please select two states.");
}
//else if($name == $name2)
//{
// apologize("Please select two different states.");
//}
else
{
$rows = query("SELECT * FROM states WHERE name = ?", $name);
$rows2 = query("SELECT * FROM states WHERE name = ?", $name2);
render("template3.php", ["rows" => $rows, "rows2" => $rows2, "ipopulation" => $ipopulation, "iarea" => $iarea, "itemp" => $itemp, "opopulation" => $opopulation, "oarea" => $oarea, "otemp" => $otemp]);
}
}
?>