<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Airline Survey</title>
</head>
<body>
<h1>Airline Survey</h1>
<?php
// opens connection to mysql server
$dbc = @mysqli_connect("localhost", "root");
if(!$dbc)
{
die("Did not connect :" . mysqli_error());
}
//selects the Database
mysqli_select_db("airlinedatabase")or die(mysqli_error());
// begins form so user can put data in database
?>
<form action="airlineSurvey.php" method ="POST" enctype="application/x-www-form-urlencoded" >
<table border="0">
<tr>
<td><center><strong>Last Name</strong></center></td>
<td><center><strong>Date of Survey</strong></center></td>
<td><center><strong>Date/Time of Flight</strong></center></td>
<td><center><strong>Flight Destination</strong></center></td>
<td><center><strong>Flight Number</strong></center></td>
<td><center><strong>Seat Number</strong></center></td>
</tr>
<tr>
<td><center><input type="text" name="lName" value="<?php echo $_POST['lName'];?>"/></center></td>
<td><center><input type="text" name="dSurvey" value="<?php echo $_POST['dSurvey'];?>"/></center></td>
<td><center><input type="text" name="dtFlight" value="<?php echo $_POST['dtFlight'];?>"/></center></td>
<td><center><input type="text" name="fDest" value="<?php echo $_POST['fDest'];?>"/></center></td>
<td><center><input type="text" name="fNum" value="<?php echo $_POST['fNum'];?>"/></center></td>
<td><center><input type="text" name="sNum" value="<?php echo $_POST['sNum'];?>"/></center></td>
</tr>
</table>
<br />
<table>
<tr>
<td> <p>Friendliness of customer staff?</p></td>
<td ><label><input type="radio" name="q1" value="1" />
No Opinion</label></td>
<td ><label><input type="radio" name="q1" value="2" />
Poor</label></td>
<td ><label><input type="radio" name="q1" value="3" />
Fair</label></td>
<td><label><input type="radio" name="q1" value="4" />
Good</label></td>
<td ><label><input type="radio" name="q1" value="5" />
Excellent</label></td>
</table>
</p>
<br />
<table>
<td><p>Space for luggage storage?</p></td>
<td ><label><input type="radio" name="q2" value="1" />
No Opinion</label></td>
<td><label><input type="radio" name="q2" value="2" />
Poor</label></td>
<td><label> <input type="radio" name="q2" value="3" />
Fair</label></td>
<td><label><input type="radio" name="q2" value="4" />
Good</label></td>
<td><label><input type="radio" name="q2" value="5" />
Excellent</label></td>
</table>
</p>
<br />
<table>
<td><p>Comfort of Seating?</p></td>
<td><label><input type="radio" name="q3" value="1" />
No Opinion</label></td>
<td><label><input type="radio" name="q3" value="2" />
Poor</label></td>
<td><label><input type="radio" name="q3" value="3" />
Fair</label></td>
<td><label> <input type="radio" name="q3" value="4" />
Good</label></td>
<td><label> <input type="radio" name="q3" value="5" />
Excellent</label></td>
</table>
</p>
<br />
<table>
<td><p>Cleanliness of aircraft?</p></td>
<td><label><input type="radio" name="q4" value="1" />
No Opinion</label></td>
<td><label> <input type="radio" name="q4" value="2" />
Poor</label></td>
<td><label><input type="radio" name="q4" value="3" />
Fair</label></td>
<td><label><input type="radio" name="q4" value="4" />
Good</label></td>
<td ><label><input type="radio" name="q4" value="5" />
Excellent</label></td>
</table>
</p>
<br />
<table>
<td><p>Noise level of aircraft?</p></td>
<td><label><input type="radio" name="q5" value="1" />
No Opinion</label></td>
<td><label><input type="radio" name="q5" value="2" />
Poor</label></td>
<td><label><input type="radio" name="q5" value="3" />
Fair</label></td>
<td><label><input type="radio" name="q5" value="4" />
Good</label></td>
<td><label><input type="radio" name="q5" value="5" />
Excellent</label></td>
</table>
</p>
</tr>
<p><input type="submit" name = "submit" value="Submit" />
<input type="reset" value="Reset" />
<input type="submit" name ="fetch" value="Get Airline Survey Table" />
</p>
</form>
<?php
if($_POST['fetch'])
{
echo "table width = '100%' border='1'>";
echo "<tr><th>id</th><th>lName</th><th>dSurvey</th><th>dtFlight</th><th>fDest</th><th>fNum</th><th>sNum</th><th>q1</th><th>q2</th><th>q3</th><th>q4</th> <th>q5</th></tr>";
$row= mysqli_fetch_row($Qres);
do
{
echo "<tr><td>{$Row[0]}</td>";
echo "<td>{$Row[1]}</td>";
echo "<td>{$Row[2]}</td>";
echo "<td>{$Row[3]}</td>";
echo "<td>{$Row[4]}</td>";
echo "<td>{$Row[5]}</td>";
echo "<td>{$Row[6]}</td>";
echo "<td>{$Row[7]}</td>";
echo "<td>{$Row[8]}</td>";
echo "<td>{$Row[9]}</td>";
echo "<td>{$Row[10]}</td>";
echo "<td>{$Row[11]}</td>";
$row = mysqli_fetch_row($Qres);
} While($row);
}
if($_POST['submit'])
{
$lName = $_POST['lName'];
$curnum = 0;
if(!$lName)
{
$curnum ++;
echo $curnum . ". You didnt enter a Last Name! <br>
";
}
$sqls = "SELECT * FROM `airlinesurvey` WHERE lName='".$lName."'";
$Qres = mysqli_query($sqls) or die(mysqli_error());
if(mysql_num_rows($Qres) > 0)
{
$curnum ++;
echo $curnum ." . The Last name '".$lName."' allready exists!<br>";
}
if($curnum == 0)
{
mysqli_query("INSERT INTO `airlinesurvey` VALUES(`id`,'".$lName."')") or die(mysqli_error());
}
}
?>
</body>
</html>