-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRent.php
More file actions
178 lines (130 loc) · 3.98 KB
/
Copy pathRent.php
File metadata and controls
178 lines (130 loc) · 3.98 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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<title>Vehicle Rental Management System</title>
<style type="text/css">
#header
{
background-color:lightblue;
height:75px;
font-family:cursive;
}
h1
{
margin-bottom:0;
margin-top:0;
text-align:center;
color:cornsilk;
font-size:60px;
}
#menu
{
background-color:lightblue;
height:500px;
width:200px;
float:left;
font-size:20px;
color:cornsilk;
font-family:cursive
}
#content
{
background-color:whitesmoke;
height:500px;
float:center;
color:darkblue;
font-size:20px;
font-family:bimini;
}
#footer
{
background-color:lightblue;
clear:both;
text-align:center;
color:cornsilk;
font-family:cursive;
}
.menuButtons:link, .menuButtons:visited
{
display:block;
color:cornsilk;
width:195px;
height:26px;
padding:0px;
margin:5px;
text-decoration:none;
}
.menuButtons:hover, .menuButtons:active
{
background-color:black;
}
</style>
</head>
<body bgcolor="#FFFFFF" style="margin:0;">
<div id="container">
<div id="header">
<h1><b>Rent</b></h1>
</div>
<div id="menu" >
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Rent.php">Rent</a>
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Return.php">Return</a>
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Add.php">Add</a>
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Edit.php">Edit</a>
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Delete.php">Delete</a>
<br />
<a class="menuButtons" href="https://userpages.umbc.edu/~nreed2/461/Search.php">Search</a>
<br />
</div>
<div id="content">
<?php
$mysql_user = "rlevin2";
$mysql_password = "harryhml";
$mysql_database = "rlevin2";
/* Connect to database */
mysql_connect("studentdb.gl.umbc.edu", $mysql_user, $mysql_password) or die("Can't connect to MySQL.");
mysql_select_db($mysql_database) or die("Can't connect to database.");
echo "Please enter the following information and click 'Submit' to rent a vehicle.<br><br>";
if(isset($_POST['VehicleID']) && isset($_POST['CustomerID']) && isset($_POST['Cost']) && isset($_POST['DateRent']) && isset($_POST['DateReturn']) && isset($_POST['Insurance']))
{
if(!is_numeric($_POST['VehicleID']) || !is_numeric($_POST['CustomerID']) || !is_numeric($_POST['Cost']))
echo "Not valid input.<br><br>";
else if(!is_string($_POST['DateRent']) || !is_string($_POST['DateReturn']))
echo "Not valid input.<br><br>";
else if(!preg_match("#([0-9]+){4}\-([0-9]+){2}\-([0-9]+){2}#", $_POST['DateRent']) && !preg_match("#([0-9]+){4}\-([0-9]+){2}\-([0-9]+){2}#", $_POST['DateReturn']))
echo "Not valid input.<br><br>";
else if(strlen(substr($_POST['Cost'], strpos($_POST['Cost'], '.') + 1)) != 2)
echo "Not valid input yup.<br><br>";
else if(!$insert = mysql_query("INSERT INTO Policy (VehicleID, CustomerID, Cost, DateRent, DateReturn, Insurance) VALUES ('$_POST[VehicleID]', '$_POST[CustomerID]', '$_POST[Cost]', '$_POST[DateRent]', '$_POST[DateReturn]', '$_POST[Insurance]')"))
echo "Can't submit information.<br><br>";
else
{
echo "Succesfully rented car. Your rental ID number is " . mysql_insert_id();
echo ".<br><br>";
}
}
else
echo "You must fill in all the information.<br><br>";
mysql_close();
?>
<form name="input" action="" method="POST">
Vehicle ID: <input type="text" name="VehicleID"><br>
Customer ID: <input type="text" name="CustomerID"><br>
Cost (##.##): <input type="text" name="Cost"><br>
Date Rented (YYYY-MM-DD): <input type="text" name="DateRent"><br>
Date Returned (YYYY-MM-DD): <input type="text" name="DateReturn"><br>
Insurance?<br>
<input type="radio" name="Insurance" value=1>Yes<br>
<input type="radio" name="Insurance" value=0>No<br><br>
<input type="submit" value="Submit">
</form>
</div>
<div id="footer">
By Neva Reed, Ross Levin, Tim LaCotti</div>
</div>
</body>
</html>