-
Notifications
You must be signed in to change notification settings - Fork 0
/
read.php
150 lines (132 loc) · 5.2 KB
/
read.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
<?php
// Check existence of id parameter before processing further
if(isset($_GET["id"]) && !empty(trim($_GET["id"]))){
// Include config file
require_once 'config.php';
// Prepare a select statement
$sql = "SELECT * FROM carinfo WHERE id = :id";
if($stmt = $pdo->prepare($sql)){
// Bind variables to the prepared statement as parameters
$stmt->bindParam(':id', $param_id);
// Set parameters
$param_id = trim($_GET["id"]);
// Attempt to execute the prepared statement
if($stmt->execute()){
if($stmt->rowCount() == 1){
/* Fetch result row as an associative array. Since the result set
contains only one row, we don't need to use while loop */
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// Retrieve individual field value
$Year = $row["Year"];
$Make = $row["Make"];
$Model = $row["Model"];
$VID = $row["VID"];
$Mileage = $row["CurrentMileage"];
$Tag = $row["LicenseTag"];
$InsCarrier = $row["InsuranceProvider"];
$InsPlcy = $row["InsurancePolicy"];
} else{
// URL doesn't contain valid id parameter. Redirect to error page
header("location: error.php");
exit();
}
} else{
echo "Oops! Something went wrong. Please try again later.";
}
}
// Close statement
unset($stmt);
// Close connection
unset($pdo);
} else{
// URL doesn't contain id parameter. Redirect to error page
header("location: error.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html">
<title>CarQuest</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
$(function() {
$('#header').load('menu.html');
});
</script>
<style type="text/css">
<!--
body,td,th {
color: LightGray;
}
body {
background-color: SlateGray;
}
a:link {
color: White;
}
-->
</style>
</head>
<body>
<div class="container">
<!–– displays menu ––>
<header>
<div id="header">
</div>
</header>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header"style = "width:200px; color:LightBlue;">
<h1>View Record</h1>
</div>
<form class="form-inline">
<div class="form-group mb-2">
<div class="col-lg-12">Year:</div>
<p class="form-control"><?php echo $Year; ?></p>
</div>
<div class="form-group mb-2">
<div class="col-lg-12">Make:</div>
<p class="form-control"><?php echo $Make; ?></p>
</div>
<div class="form-group mb-2">
<div class="col-lg-12">Model:</div>
<p class="form-control"><?php echo $Model; ?></p>
</div>
</form>
<div class="form-group">
<div class="col-sm-4">VIN:</div>
<p class="form-control-static"><?php echo $VID; ?></p>
</div>
<div class="form-group">
<div class="col-sm-4">Mileage:</div>
<p class="form-control-static"><?php echo $Mileage; ?></p>
</div>
<div class="form-group">
<div class="col-sm-4">TAG:</div>
<p class="form-control-static"><?php echo $Tag; ?></p>
</div>
<div class="form-group">
<div class="col-sm-4">Insurance Carrier:</div>
<p class="form-control-static"><?php echo $InsCarrier; ?></p>
</div>
<div class="form-group">
<div class="col-sm-4">Insurance Policy:</div>
<p class="form-control-static"><?php echo $InsPlcy; ?></p>
</div>
<p><a href="carinfo.php" class="btn btn-default">Back</a></p>
</div>
</div>
</div>
</div>
</body>
</html>