Hi, I need to create a web page that stores airline surveys in a MYSQL database.
ID: 3635291 • Letter: H
Question
Hi, I need to create a web page that stores airline surveys in a MYSQL database. I have created two php pages and html page but they don't work. Someone please help me ASAP!my Survey.html page
<!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="no_op" value="No Opinion" />No Opinion<br />
<input type="radio" name="poor" value="Poor" />Poor<br />
<input type="radio" name="fair" value="Fair" />Fair<br />
<input type="radio" name="good" value="Good" />Good<br />
<input type="radio" name="exc" value="Excellent" />Excellent<br /><br />
<p>Space for luggage storage</p><br />
<input type="radio" name="no_op" value="No Opinion" />No Opinion<br />
<input type="radio" name="poor" value="Poor" />Poor<br />
<input type="radio" name="fair" value="Fair" />Fair<br />
<input type="radio" name="good" value="Good" />Good<br />
<input type="radio" name="exc" value="Excellent" />Excellent<br /><br />
<p>Comfort of seating</p><br />
<input type="radio" name="no_op" value="No Opinion" />No Opinion<br />
<input type="radio" name="poor" value="Poor" />Poor<br />
<input type="radio" name="fair" value="Fair" />Fair<br />
<input type="radio" name="good" value="Good" />Good<br />
<input type="radio" name="exc" value="Excellent" />Excellent<br /><br />
<p>Cleanliness of aircraft</p><br />
<input type="radio" name="no_op" value="No Opinion" />No Opinion<br />
<input type="radio" name="poor" value="Poor" />Poor<br />
<input type="radio" name="fair" value="Fair" />Fair<br />
<input type="radio" name="good" value="Good" />Good<br />
<input type="radio" name="exc" value="Excellent" />Excellent<br /><br />
<p>Noise level of aircraft</p><br />
<input type="radio" name="no_op" value="No Opinion" />No Opinion<br />
<input type="radio" name="poor" value="Poor" />Poor<br />
<input type="radio" name="fair" value="Fair" />Fair<br />
<input type="radio" name="good" value="Good" />Good<br />
<input type="radio" name="exc" 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>
My submitsurvey.php page
<!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", "mgs314");
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>
Show Past Survey result page
<!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", "mgs314")
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>
Explanation / Answer
<!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>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.