Create a Web page that stores airline surveys in a MySQL database. Include field
ID: 3912730 • Letter: C
Question
Create a Web page that stores airline surveys in a MySQL database. Include fields for the date and time of the flight, flight number, and other fields you consider appropriate for identifying a particular flight. Also, include groups of radio buttons that allow the user to rate the airline on the following criteria:
• Friendliness of customer staff
• Space for luggage storage
• Comfort of seating
• Cleanliness of aircraft
• Noise level of aircraft
Here is what I currently have:
Survey.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Airline Survey</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<h2>Please enter the following details</h2>
<form method="post" action="SubmitSurvey.php">
<p>Name <input type="text" name="name" /></p>
<p>Age <input type="text" name="age" /></p>
<p>Flight Number <input type="text" name="flt_no" /></p>
<p>Flight Date <input type="text" name="flt_date" /></p>
<p>Flight Time <input type="text" name="flt_time" /></p><br /><br />
<p>Friendliness of customer staff</p><br />
<input type="radio" name="friendliness" value="No Opinion" />No Opinion<br />
<input type="radio" name="friendliness" value="Poor" />Poor<br />
<input type="radio" name="friendliness" value="Fair" />Fair<br />
<input type="radio" name="friendliness" value="Good" />Good<br />
<input type="radio" name="friendliness" value="Excellent" />Excellent<br /><br />
<p>Space for luggage storage</p><br />
<input type="radio" name="storage" value="No Opinion" />No Opinion<br />
<input type="radio" name="storage" value="Poor" />Poor<br />
<input type="radio" name="storage" value="Fair" />Fair<br />
<input type="radio" name="storage" value="Good" />Good<br />
<input type="radio" name="storage" value="Excellent" />Excellent<br /><br />
<p>Comfort of seating</p><br />
<input type="radio" name="comfort" value="No Opinion" />No Opinion<br />
<input type="radio" name="comfort" value="Poor" />Poor<br />
<input type="radio" name="comfort" value="Fair" />Fair<br />
<input type="radio" name="comfort" value="Good" />Good<br />
<input type="radio" name="comfort" value="Excellent" />Excellent<br /><br />
<p>Cleanliness of aircraft</p><br />
<input type="radio" name="cleanliness" value="No Opinion" />No Opinion<br />
<input type="radio" name="cleanliness" value="Poor" />Poor<br />
<input type="radio" name="cleanliness" value="Fair" />Fair<br />
<input type="radio" name="cleanliness" value="Good" />Good<br />
<input type="radio" name="cleanliness" value="Excellent" />Excellent<br /><br />
<p>Noise level of aircraft</p><br />
<input type="radio" name="noise" value="No Opinion" />No Opinion<br />
<input type="radio" name="noise" value="Poor" />Poor<br />
<input type="radio" name="noise" value="Fair" />Fair<br />
<input type="radio" name="noise" value="Good" />Good<br />
<input type="radio" name="noise" value="Excellent" />Excellent<br /><br />
<p><input type="submit" value="Submit" />
<input type="reset" value="Reset" /></p>
</form>
<p><a href="ShowPastResults.php">Show Past Survey Results</a></p>
</body>
</html>
submitsurvey.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN
""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Survey Form</title>
</head>
<body>
<?php
if(empty($_GET["date"]) || empty($_GET["flight"]) || empty($_GET["time"]))
echo "<p>You must enter the date, flight number and departure time! Click your browser's Back button to return to the form.</p>";
else{
$DBConnect = @mysql_connect("localhost", "root", "AidanCT11");
if($DBConnect === FALSE)
echo "<p>Unable to connect to the database server.</p>"
. "<p>Error code ".mysql_errno()
. ": ".mysql_error()."</p>";
else {
$DBName = "airlineSurvey";
if(!@mysql_select_db($DBName, $DBConnect)){
$SQLstring = "CREATE DATABASE $DBName";
$QueryResult = @mysql_querry($SQLstring, $DBConnect);
if($QueryResult === FALSE)
echo "<p>Unable to execute the query.</p>"
. "<p>Error code ".mysql_errno($DBConnect)
. ": ".mysql_error($DBConnect)
."</p>";
else
echo "<p>You are the first visitor!</p>";
}
mysql_select_db($DBName, $DBConnect);
$TableName = "airlineSurvey";
$SQLstring = "SHOW TABLES LIKE '$TableName'";
$QueryResult = @mysql_query($SQLstring, $DBConnect);
if(mysql_num_rows($QueryResult) == 0){
$SQLstring = "CREATE TABLE $TableName
(countID SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
last_name VARCHAR(40), first_name VARCHAR(40))";
$QueryResult = @mysql_query($SQLstring, $DBConnect);
if($QueryResult === FALSE)
echo "<p>Unable to create the table.</p>"
. "<p>Error code ".mysql_errno($DBConnect)
. ": ".mysql_error($DBConnect)
."</p>";
}
$Date=stripslashes($_GET["date"]);
$FlightNumber=($_GET["flight"]);
$DepartureTime=($_GET["time"]);
$Friendliness=($_GET["friendliness"]);
$Cleanliness=($_GET["cleanliness"]);
$Space=($_GET["space"]);
$Noise=($_GET["noise"]);
$Comfort=($_GET["comfort"]);
$QueryResult = @mysql_query($SQLstring, $DBConnect);
if($QueryResult === FALSE)
echo "<p>Unable to execute the query.</p>"
. "<p>Error code ".mysql_errno($DBConnect)
. ": ".mysql_error($DBConnect)
."</p>";
else
echo "<p>Thank you for completing our survey!</p>";
}
mysql_close($DBConnect);
}
?>
</body>
</html>
ShowPastResults.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Past Survey Results</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$DBConnect = @mysqli_connect("localhost", "root", "AidanCT11")
if($DBConnect === FALSE) {
echo "<p>Unable to connect to the database server.</p>"
. "<p>Error code ".mysql_errno()
. ": ". mysql_error()."</p>";
else {
$DBName = "airlineSurvey";
if (!@mysqli_select_db($DBConnect, $DBName))
die("<p>There are no past surveys!</p>");
$TableName = "t_survey";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (mysql_num_rows($QueryResult) == 0)
echo"<p>There are no passengers!</p>";
else{
echo "<p>The following passengers have completed the survey:</p>";
echo "<table width='100%' border='1'>";
echo "<tr><th>Passenger Name</th></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
do {
echo "<tr><td>{$Row['psngr_name']}</td></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);
$TableName = "t_options";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (mysqli_num_rows($QueryResult) == 0)
echo"<p>There are no survey results!</p>";
echo "<p>Survey Results:</p>";
echo "<table width='100%' border='1'>";
echo "<tr><th>Friendliness of customer staff</th><th>Space for luggage storage</th><th>Comfort of seating</th><th>Cleanliness of aircraft</th><th>Noise level of aircraft</th></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
do {
echo "<tr><td>{$Row['no_op']}</td>";
echo "<td>{$Row['poor']}</td>";
echo "<td>{$Row['fair']}</td>";
echo "<td>{$Row['good']}</td>";
echo "<td>{$Row['exc']}</td></tr>";
$Row = mysqli_fetch_assoc($QueryResult);
} while ($Row);
mysql_free_result($QueryResult);
mysql_close($DBConnect);
?>
</body>
</html>
When running it, this is the error that I receive: You must enter the date, flight number and departure time! Click your browser's Back button to return to the form.
That message is consistent even though I enter a date and time.
When clicking to see who has inserted a result this is what I receive: ou must enter the date, flight number and departure time! Click your browser's Back button to return to the form.
If there is any assistance I get with this it would be appreciated.
Explanation / Answer
<p>Flight Number <input type="text" name="flight" /></p>
<p>Flight Date <input type="text" name="date" /></p>
<p>Flight Time <input type="text" name="time" /></p><br /><br />
Change the name's of the fields, respective to GET parameters. If it is unmatched you will get that message...
If you have any doubts, please give me comment...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.