Is it even possible to create a .txt document from a survey that includes list options? Here are my files:
html Code:
<title>Airline Survey</title>
<style type="text/css">
<!--
body {
background-color: #FFFFCC;
}
-->
</style></head>
<body>
<h2>How Was Your Flight?</h2>
<form action="TakeSurvey.php" method="get" enctype="application/x-www-form-urlencoded" name="AirlineSurvey" id="AirlineSurvey">
<p>Today's Date <input type="text" name="date" /></p>
<p>Flight Number <input type="text" name="flight" /></p>
<p>Departure Time <input type="text" name="time" /></p>
<p>
<table width="710" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="359">
<strong>Friendliness of customer staff?
</label>
</strong></td>
<td width="337"><strong> Cleanliness of aircraft? </strong></td>
</tr>
<tr>
<td>
<select name="friendliness" size="2" id="friendliness">
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="No_Opinion">No Opinion</option>
<option value="Poor">Poor</option>
</select> </td>
<td>
<select name="cleanliness" size="2" id="cleanliness">
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="No Opinion">No Opinion</option>
<option value="Poor">Poor</option>
</select> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> <strong>Space for luggage storage? </strong></td>
<td> <strong>Noise level of aircraft? </strong></td>
</tr>
<tr>
<td>
<select name="space" size="2" id="space">
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="No Opinion">No Opinion</option>
<option value="Poor">Poor</option>
</select> </td>
<td>
<select name="noise" size="2" id="noise">
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="No Opinion">No Opinion</option>
<option value="Poor">Poor</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>
<strong>Comfort of seating?
</label>
</strong></td>
<td> </td>
</tr>
<tr>
<td>
<select name="comfort" size="2" id="comfort">
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="No Opinion">No Opinion</option>
<option value="Poor">Poor</option>
</select> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit" /></td>
<td><input name="Reset" type="reset" id="Reset" value="Reset" /></td>
</tr>
</table>
</form>
<p><a href="ShowSurvey.php"><strong>View Past Survey Results</strong></a></p>
</body>
My first PHP document:
php Code:
<title>Survey Form</title>
</head>
<body>
<?php
if (empty($_GET&
#91;'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 RSVP form. </p>";
else {
$Friendliness= ($_GET['friendliness']);
$Space =($_GET['space']);
$Comfort= ($_GET['comfort']);
$Noise= ($_GET['noise']);
$Survey=
fopen("survey.txt",
"a");
if (fwrite($Survey,
$Date .
"," .
$FlightNumber .
"," .
$DepartureTime .
"\r\n")) echo "<p>Thank you for completing our survey!</p>";
else
echo "<p>Cannot add your information to the survey. </p>";
}
else
echo "<p>Cannot write to the file.</p>";
}
?>
</body>
And my show survey results php:
php Code:
<title>Show Survey</title>
</head>
<body>
<?php
echo "<p>The following are results from past surveys:</p><pre>";
}
else
echo "<p>The Surveys cannot be read.</p>";
?>
<hr /><p><a href="AirlineSurvey.html">Return to Survey Page</a></p>
</body>
This is my first semester in PHP and the &*$%$ book doesn't mention how to get results when you use list/menu in your form (which they required for this assignment)
The text box entries show up just fine .
Thanks for any assistance,
Gizelle