-
Notifications
You must be signed in to change notification settings - Fork 0
/
found.php
74 lines (60 loc) · 1.96 KB
/
found.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
<!--
Found Something Page
By Kulvinder Lotay and Artur Barbosa
-->
<!DOCTYPE html>
<html>
<?php
# Connect to MySQL server and the database
require( 'includes/connect_db.php' ) ;
# Includes these helper functions
require( 'includes/helpers.php' ) ;
# If user requests item (clicks quick link) make the appropriate GET request from quick links
if ($_SERVER[ 'REQUEST_METHOD' ] == 'GET') {
if(isset($_GET['id']) && isset($_GET['p'])){
header('Location: /ql.php?id=' . $_GET['id'] . '&p=' . $_GET['p']);
}
}
# Otherwise, user submitted the form, so let's validate
/*else if ($_SERVER[ 'REQUEST_METHOD' ] == 'POST') {
$errors = array();
$num = trim($_POST['num']) ;
$fname = trim($_POST['fname']) ;
$lname = trim($_POST['lname']) ;
# Validate president number
if (!valid_number($num)){
$errors[] = 'number';
#echo '<p style="color:red; font-size:16px;">Please provide a valid president number.</p>' ;
}
# Validate first name
if (!valid_name($fname)){
$errors[] = 'first name';
#echo '<p style="color:red; font-size:16px;">Please provide a first name.</p>' ;
}
# Validate last name
if (!valid_name($lname)){
$errors[] = 'last name';
#echo '<p style="color:red; font-size:16px;">Please provide a last name.</p>' ;
}
if (!empty($errors)){
echo '<span style="color: red">Error! Please enter the president</span>' ;
foreach ( $errors as $field ) {
echo '<span style="color: red; font-style: italic;"> - ' . $field . '</span>' ;
}
}
else {
$result = insert_record($dbc, $num, $fname, $lname) ;
echo "<p>Successfully added $fname $lname into Dead Presidents.</p>" ;
}
}*/
# Store current page in variable, call show_links and show_records functions using cur_page variable
$cur_page = $_SERVER['PHP_SELF'];
show_links($dbc, $cur_page);
# Display found page with recenlty found items
show_page($cur_page, $dbc);
# Display the footer
show_footer();
# Close the connection
mysqli_close( $dbc ) ;
?>
</html>