NameSilo

Form Not Displaying

Spaceship Spaceship
Watch

aal814

Established Member
Impact
0
I believe this code is correct, however the form is not displaying when I load the page. Anyone know why
Code:
<?php

//This code will allow a pilot to fill out a PIREP and have the hours automatically transferred into his account.

$page_title = 'File a PIREP';

if (isset($_POST['submit'])) {  //Handle the form

	//Check for a Pilot ID
		if (strlen($_POST['Pilot_Id'])>0) {
			$pid = TRUE;
		} else {
			$pid = FALSE;
			echo '<font color="red">You forgot to enter your departure time.</font>';
		}
		
	//Check for a Password
		if (strlen($_POST['password'])>0) {
			$password = TRUE;
		} else {
			$password = FALSE;
			echo '<font color="red">You forgot to enter your departure time.</font>';
		}
	
	//Check for a Departure time hours
		if (strlen($_POST['departurehours'])>0) {
			$departurehours = TRUE;
		} else {
			$departuretime = FALSE;
			echo '<font color="red">You forgot to enter your departure time hour.</font>';
		}
		
	//Check for a Departure time minutes
		if (strlen($_POST['departureminutes'])>0) {
			$departureminutes = TRUE;
		} else {
			$departureminutes = FALSE;
			echo '<font color="red">You forgot to enter your departure time minutes.</font>';
		}
		
	//Check for an Arrival Time
		if (strlen($_POST['arrivalhours'])>0) {
			$arrivalhours = TRUE;
		} else {
			$arrivalhours = FALSE;
			echo '<font color="red">You forgot to enter your arrival hours.</font>';
		}
		
	//Check for Arrival time minutes
		if (strlen($_POST['arrivalminutes'])>0) {
			$arrivalminutes = TRUE;
		} else {
			$arrivalminutes = FALSE;
			echo '<font color="red">You forgot to enter your arrival minutes.</font>';
		}
		
		
	if ($pid && $password && $departurehours && $departureminutes && $arrivalhours && $arrivalminutes) {
		
		$pid = $_POST['Pilot_ID'];
		$password = $_POST['password'];
		$departurehours = $_POST['departurehours'];
		$departureminuted = $_POST['departureminutes'];
		$arrivalhours = $_POST['arrivalhours'];
		$arrivalminutes = $_POST['arrivalminutes'];
		
								
		require_once('mysql_connect.php');
		
			//Make the query to retrieve pilots current hours.
			$query = "SELECT Hours from pilotroster WHERE Pilot_ID = '$pid'";
			
			$result = @mysql_query($query);
			
			If ($result) { //If query is sucesfull
				($oldhours = $result);
				($totalhours = ($oldhours + $newhours));
							
					//Update record with new total hours
					$query = "UPDATE pilotroster SET Hours = '$totalhours' WHERE Pilot_ID = '$pid'";
					
					$result = @mysql_query($query); //Run the query.
					If ($result) { //If everything ran Ok
									echo '<p><b>Your PIREP has been filed and the database updated.</b></p>';
									exit();
									} else { //If it did not run OK.
									$message = '<p>Sorry your PIREP could not be filed.<br>Please contact your HUB Manager.<p \>Regards, <p \>The BMI Virtual Management.< p\><p>' . mysql_error() . '</p>';
								}
				}else{
					$message =  '<p>Sorry, your Pilot ID could not be located within our database.<br>Please contact your HUB Manager.<p>Regards,<p>The BMI Virtual Management</p>';
					}
					mysql_close(); //Close the database connection.
		} else {
			$message .= '<p>Please try again.</p>';
	} //End of main submit conditional.
	?>

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  <table width="52%" border="0">
    <tr> 
      <td width="39%" ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Pilot 
        ID:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="text" name="Pilot_ID value=""></td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Password:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="password" name="password"></td>
    </tr>
    <tr> 
      <td align="right"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Flight 
        Number:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="text" name="flightnumber"></td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Departure 
        Gate:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="text" name="departuregate"></td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Departure 
        Time:</strong></font></td>
      <td width="31%" ALIGN="RIGHT"> Hrs 
        <input name="departurehours" type="text" maxlength="2" size = "10"></td>
      <td width="30%" ALIGN="LEFT"><input type="text" name="departureminutes" maxlength="2" size="10">
        Min</td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Arrival 
        Time:</strong></font></td>
      <td ALIGN="RIGHT">Hrs 
        <input name="arrivalhours" type="text" maxlength="2" SIZE="10"></td>
      <td ALIGN="LEFT"><input type="text" name="arrivalminutes" laxlength="2" size="10">
        Min</td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Arrival 
        Gate:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="text" name="arrivalgate"></td>
    </tr>
    <tr> 
      <td ALIGN="RIGHT"><font color="#0066FF" face="Arial, Helvetica, sans-serif"><strong>Fuel 
        Consumption:</strong></font></td>
      <td colspan="2" ALIGN="CENTER"><input type="text" name="textfield8"></td>
    </tr>
    <tr> 
      <td align="center" colspan="3"><input type="submit" name="Submit" value="File PIREP"></td>
    </tr>
  </table>
</form>

<?php 
} //End of main submit conditional.

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
You have this line of code in the beginning of the script:

PHP:
if (isset($_POST['submit'])) {

That means that anything in that if statement will execute when the form is submitted.

The closing bracket for that if statement is at the end of the code. Your closing bracket should be before the HTML that displays the form, otherwise the form will only be displayed when the form is submitted.
 
0
•••
EDIT: gamex beat me to it ;)
 
0
•••
oooo, which VA is this?
 
0
•••
Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back