I have FlightSurvey.html, EnterFlightSurvey.php, and ShowSurveyResults.php
When entering data, i cannot figure out how to get the radio buttons to be entered into the database... they don't show up on the 'surveys' table.
Secondly, it tells me error #1064 when i press the submit button
third, when I try to see 'past survey results" i get a bunch of undefined indexes for ShowSurveryResults.php for the radio button names- and they don't show up in the table. Any help would be appreciated... I've tried this a few different ways and nothing seems to be working.
<h2> Tell us how we did! Enter your flight information and rate our services</h2>
<form method="POST" action="EnterFlightSurvey.php">
<p>Flight Date <input type="text" name="flight_date" /></p>
<p>Flight Time <input type="text" name="flight_time" /></p>
<p>Flight Number <input type="text" name="flight_number" /></p>
<p><b>Friendliness of Staff:</b>
<input type="radio" name="friendly" value="No Opinion" />No Opinion
<input type="radio" name="friendly" value="Poor" />Poor
<input type="radio" name="friendly" value="Fair" />Fair
<input type="radio" name="friendly" value="Good" />Good
<input type="radio" name="friendly" value="Excellent" />Excellent <br /> </p>
<p><b>Space for luggage storage:</b><input type="radio" name="space" value="No Opinion" /> No Opinion
<input type="radio" name="space" value="Poor" /> Poor
<input type="radio" name="space" value="Fair" /> Fair
<input type="radio" name="space" value="Good" /> Good
<input type="radio" name="space" value="Excellent" /> Excellent <br /> </p>
<p><b>Comfort of seating:</b><input type="radio" name="comfort" value="No Opinion" /> No Opinion
<input type="radio" name="comfort" value="Poor" /> Poor
<input type="radio" name="comfort" value="Fair" /> Fair
<input type="radio" name="comfort" value="Good" /> Good
<input type="radio" name="comfort" value="Excellent" /> Excellent <br /> </p>
<p><b>Cleanliness of aircraft:</b><input type="radio" name="clean" value="No Opinion" /> No Opinion
<input type="radio" name="clean" value="Poor" /> Poor
<input type="radio" name="clean" value="Fair" /> Fair
<input type="radio" name="clean" value="Good" /> Good
<input type="radio" name="clean" value="Excellent" /> Excellent <br /> </p>
<p><b>Noise level of aircraft:</b><input type="radio" name="noise" value="No Opinion" /> No Opinion
<input type="radio" name="noise" value="Poor" /> Poor
<input type="radio" name="noise" value="Fair" /> Fair
<input type="radio" name="noise" value="Good" /> Good
<input type="radio" name="noise" value="Excellent" /> Excellent <br /> </p>
<p><input name="" type="submit" value="Submit" /></p>
</form>
<p><a href="ShowSurveyResults.php">Show Past Surveys</a></p>
EnterFlightSurvey.php
<?php
if(empty($_POST['flight_time']) || empty($_POST['flight_date']) || empty($_POST['flight_number'])) {
echo "<p>You must enter the flight time, date, and number! Clck your browser's Back button to return to the Guest Book form.</p>";
} else {
$DBConnect = @mysql_connect("localhost", "root", "root");
if($DBConnect === FALSE) {
echo "<p>Unable to connect to the database server.</p>"
. "<p>Error code ".mysql_errmo()
. ": ".mysql_error()."</p>";
} else {
$DBName = "flightsurvey";
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 to complete the survey!</p>";
}
}
mysql_select_db($DBName, $DBConnect);
$TableName = "surveys";
$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,
flight_time varchar(40), flight_date varchar(8), flight_number varchar(20), friendly, space, comfort, clean, noise)";
$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>";
}
}
$FlightDate = stripslashes($_POST['flight_date']);
$FlightNumber = stripslashes($_POST['flight_number']);
$FlightTime = stripslashes($_POST['flight_time']);
$Friendly = stripslashes($_POST['friendly']);
$Space = stripslashes($_POST['space']);
$Comfort = stripslashes($_POST['comfort']);
$Clean = stripslashes($_POST['clean']);
$Noise = stripslashes($_POST['noise']);
$SQLstring = "insert into $TableName values(NULL, '$FlightDate', '$FlightNumber', '$FlightTime', '$Friendly', '$Space', '$Comfort'. '$Clean', '$Noise')";
$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 "<h1>Thank you for taking our survey!</h1>";
}
}
mysql_close($DBConnect);
?>
ShowSurveyResults.php
<?php
$DBConnect = @mysql_connect("localhost", "root", "root");
if($DBConnect === FALSE) {
echo "<p>Unable to connect to the database server.</p>"
. "<p>Error code ".mysql_errmo()
. ": ".mysql_error()."</p>";
} else {
$DBName = "flightsurvey";
if(!@mysql_select_db($DBName, $DBConnect)){
echo "<p>There are no entries in the guest book!</p>";
} else {
$TableName = "surveys";
$SQLstring = "select * from $TableName";
$QueryResult = @mysql_query($SQLstring, $DBConnect);
if(mysql_num_rows($QueryResult) == 0){
echo "<p>There are no surveys completed</p>";
} else {
echo "<p>The following surveys are completed:</p>";
echo "<table with='100%' border='1'>";
echo "<tr><th>Flight Date</th><th>Flight Time</th><th>Flight Number</th><th>Friendliness of 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>";
while(($Row = mysql_fetch_assoc($QueryResult)) !== FALSE){
echo "<tr><td>{$Row['flight_date']}</td>";
echo "<td>{$Row['flight_time']}</td>";
echo "<td>{$Row['flight_number']}</td>";
echo "<td>{$Row['friendly']}</td>";
echo "<td>{$Row['space']}</td>";
echo "<td>{$Row['comfort']}</td>";
echo "<td>{$Row['clean']}</td>";
echo "<td>{$Row['noise']}</td></tr>";
}
echo "</table>";
}
mysql_free_result($QueryResult);
}
}
mysql_close($DBConnect);
?>