Jump to content

VinceGledhill

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by VinceGledhill

  1. Hi wildteen88. Thanks for your message. Here is my input form <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "TheUserName"; $password = 'thepassword'; $db_name = 'DBname'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $username = mysql_real_escape_string($_POST['username']); $height_above = mysql_real_escape_string($_POST['height_above']); $mb_diff = mysql_real_escape_string($_POST['mb_diff']); $alternative = mysql_real_escape_string($_POST['alternative']); $ppr = mysql_real_escape_string($_POST['ppr']); $general_location = mysql_real_escape_string($_POST['general_location']); $location_grid = mysql_real_escape_string($_POST['location_grid']); $runway_numbers = mysql_real_escape_string($_POST['runway_numbers']); $circuit_direction = mysql_real_escape_string($_POST['circuit_direction']); $circuit_height = mysql_real_escape_string($_POST['circuit_height']); $runway_length = mysql_real_escape_string($_POST['runway_length']); $surface = mysql_real_escape_string($_POST['surface']); $food = mysql_real_escape_string($_POST['food']); $radio_frequency = mysql_real_escape_string($_POST['radio_frequency']); $radio_callsign = mysql_real_escape_string($_POST['radio_callsign']); $radio_type = mysql_real_escape_string($_POST['radio_type']); $other_radio = mysql_real_escape_string($_POST['other_radio']); $fuel = mysql_real_escape_string($_POST['fuel']); $landing_fee = mysql_real_escape_string($_POST['landing_fee']); $operating_hours = mysql_real_escape_string($_POST['operating_hours']); $maintenance = mysql_real_escape_string($_POST['maintenance']); $hangarage = mysql_real_escape_string($_POST['hangarage']); $parking = mysql_real_escape_string($_POST['parking']); $accommodation = mysql_real_escape_string($_POST['accommodation']); $school = mysql_real_escape_string($_POST['school']); $remarks = mysql_real_escape_string($_POST['remarks']); $warnings = mysql_real_escape_string($_POST['warnings']); $weblinks = mysql_real_escape_string($_POST['weblinks']); $operator = mysql_real_escape_string($_POST['operator']); $google_image = mysql_real_escape_string($_POST['google_image']); $errorstring = ""; // default value of errorstring if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "myprivatekey"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($username =="") $errorstring = $errorstring. "Airfield Name<br>"; if ($height_above =="") $errorstring = $errorstring. "Height Above Mean Sea Level<br>"; if ($mb_diff =="") $errorstring = $errorstring. "mb Difference<br>"; if ($alternative =="") $errorstring = $errorstring. "Alternative Airfield<br>"; if ($general_location =="") $errorstring = $errorstring. "General Location<br>"; if ($location_grid =="") $errorstring = $errorstring. "Grid Reference<br>"; if ($runway_numbers =="") $errorstring = $errorstring. "Runway Numbers<br>"; if ($circuit_direction =="") $errorstring = $errorstring. "Circuit Direction<br>"; if ($circuit_height =="") $errorstring = $errorstring. "Circuit Height<br>"; if ($runway_length =="") $errorstring = $errorstring. "Runway Length<br>"; if ($radio_frequency =="") $errorstring = $errorstring. "Radio Frequency<br>"; if ($radio_callsign =="") $errorstring = $errorstring. "Radio Callsign<br>"; if ($other_radio =="") $errorstring = $errorstring. "Other Radio<br>"; if ($landing_fee =="") $errorstring = $errorstring. "Landing Fee<br>"; if ($remarks =="") $errorstring = $errorstring. "Remarks<br>"; if ($warnings =="") $errorstring = $errorstring. "Warnings<br>"; if ($weblinks =="") $errorstring = $errorstring. "Web Links<br>"; if ($operator =="") $errorstring = $errorstring. "Operator<br>"; if ($google_image =="") $errorstring = $errorstring. "Google Image<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; $insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr, general_location, location_grid, runway_numbers, circuit_direction, circuit_height, runway_length, surface, food, radio_frequency, radio_callsign, radio_type, other_radio, fuel, landing_fee, operating_hours, maintenance, hangarage, parking, accommodation, school, remarks, warnings, weblinks, operator, google_image) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr', '$general_location', '$location_grid', '$runway_numbers', '$circuit_direction', '$circuit_height', '$runway_length', '$surface', '$food', '$radio_frequency', '$radio_callsign', '$radio_type', '$other_radio', '$fuel', '$landing_fee', '$operating_hours', '$maintenance', '$hangarage', '$parking', '$accommodation' , '$school', '$remarks', '$warnings', '$weblinks', '$operator', '$google_image')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your airfield has been submitted."; include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#c9e1d0"> <caption> Submit Your Airfield Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Airfield Name</td> <td><input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'></td> <td>Ince Blundell</td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above' size = '40' maxlength= '30'value = '<?php echo $height_above; ?>'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'value = '<?php echo $mb_diff; ?>'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td> <select name = "ppr"> <option value = "Yes" <?php if ($_POST['ppr'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['ppr'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>General Location</td> <td><input type='text' name='general_location' size = '40' maxlength='50' value = '<?php echo $general_location; ?>' /></td> <td>3 Nm North Luton</td> </tr> <tr> <td> </td> <td>Location Grid Reference</td> <td><textarea name= "location_grid" input type = 'text' rows = "2" cols = "29" /><?php echo $location_grid; ?></textarea></td> <td> 53°57'7.68"N<br /> 1°10'30.33"W</td> </tr> <tr> <td> </td> <td>Runway Numbers</td> <td><textarea name= "runway_numbers" input type = 'text' rows = "5" cols = "29" /><?php echo $runway_numbers; ?></textarea></td> <td><p>This format please<br /> 05-23<br /> 18-36<br /> 14-22 </p></td> </tr> <tr> <td> </td> <td>Circuit Direction</td> <td><textarea name= "circuit_direction" input type = "text" rows = "5" cols = "29" /><?php echo $circuit_direction; ?></textarea></td> <td><p>05-LH<br /> 23-RH<br /> 14-LH </p></td> </tr> <tr> <td> </td> <td>Circuit Height</td> <td><input type='text' name='circuit_height' size = '40' maxlength='50' value = '<?php echo $circuit_height; ?>' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' value = '<?php echo $runway_length; ?>' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td> <select name = "surface"> <option value = "Grass" <?php if ($_POST['surface'] == 'Grass') { echo 'selected="selected"'; } ?>>Grass</option> <option value = "Tarmac" <?php if ($_POST['surface'] == 'Tarmac') { echo 'selected="selected"'; } ?>>Tarmac</option> <option value = "Concrete" <?php if ($_POST['surface'] == 'Concrete') { echo 'selected="selected"'; } ?>>Concrete</option> <option value = "Dirt" <?php if ($_POST['surface'] == 'Dirt') { echo 'selected="selected"'; } ?>>Dirt</option> </select> <!-- <select name = "surface"> <option value = "Grass">Grass</option> <option value="Tarmac">Tarmac</option> <option value ="Concrete">Concrete</option> <option value = "Dirt">Dirt</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Food?</td> <td> <select name = "food"> <option value = "Cafe" <?php if ($_POST['food'] == 'Cafe') { echo 'selected="selected"'; } ?>>Cafe</option> <option value = "None" <?php if ($_POST['food'] == 'None') { echo 'selected="selected"'; } ?>>None</option> <option value = "Tea and Coffee" <?php if ($_POST['food'] == 'Tea and Coffee') { echo 'selected="selected"'; } ?>>Tea and Coffee</option> <option value = "Make Your Own" <?php if ($_POST['food'] == 'Make Your Own') { echo 'selected="selected"'; } ?>>Make Your Own</option> </select> <!-- <select name = "food"> <option value = "Cafe">Cafe</option> <option value="None">None</option> <option value ="Tea and Coffee">Tea and Coffee</option> <option value = "Make Your Own">Make Your Own</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Radio Frequency</td> <td><input type='text' name='radio_frequency' size = '40'maxlength='50' value = '<?php echo $radio_frequency; ?>' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' value = '<?php echo $radio_callsign; ?>' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td> <select name = "radio_type"> <option value = "Safety Com" <?php if ($_POST['radio_type'] == 'Safety Com') { echo 'selected="selected"'; } ?>>Safety Com</option> <option value = "Air Ground" <?php if ($_POST['radio_type'] == 'Air Ground') { echo 'selected="selected"'; } ?>>Air Ground</option> <option value = "Approach" <?php if ($_POST['radio_type'] == 'Approach') { echo 'selected="selected"'; } ?>>Approach</option> <option value = "Tower" <?php if ($_POST['radio_type'] == 'Tower') { echo 'selected="selected"'; } ?>>Tower</option> </select> <!-- <select name = "radio_type"> <option value = "Sefety Com">Safety Com</option> <option value="Air Ground">Air Ground</option> <option value ="Approach">Approach</option> <option value = "Tower">Tower</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Other Radio</td> <td><input type='text' name='other_radio' size = '40' maxlength='50' value = '<?php echo $other_radio; ?>' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td> <select name = "fuel"> <option value = "AvGas" <?php if ($_POST['fuel'] == 'AvGas') { echo 'selected="selected"'; } ?>>AvGas</option> <option value = "MoGas" <?php if ($_POST['fuel'] == 'MoGas') { echo 'selected="selected"'; } ?>>MoGas</option> <option value = "AvGas and MoGas" <?php if ($_POST['fuel'] == 'AvGas and MoGas') { echo 'selected="selected"'; } ?>>AvGas and MoGas</option> <option value = "We will sort you some" <?php if ($_POST['fuel'] == 'We will sort you some') { echo 'selected="selected"'; } ?>>We will sort you some</option> <option value = "None" <?php if ($_POST['fuel'] == 'None') { echo 'selected="selected"'; } ?>>None</option> </select> <!-- <select name = "fuel"> <option value = "AvGas">AvGas</option> <option value="MoGas">MoGas</option> <option value ="AvGas and MoGas">AvGas and MoGas</option> <option value = "We will sort you some">We will sort you some</option> <option value = "None">None</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Landing Fee</td> <td><input type='text' name='landing_fee' size = '40' maxlength='50' value = '<?php echo $landing_fee; ?>' /></td> <td>£ or Nill </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td> <select name = "operating_hours"> <option value = "SR - SS" <?php if ($_POST['operating_hours'] == 'SR - SS') { echo 'selected="selected"'; } ?>>SR - SS</option> <option value="Other - See Remarks" <?php if ($_POST['operating_hours'] == 'Other - See Remarks') { echo 'selected="selected"'; } ?>>Other - See Remarks</option> </select> <!-- <select name = "operating_hours"> <option value = "SR - SS">Sunrise - Sunset</option> <option value="See Remarks">Other - See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Maintenance?</td> <td> <select name = "maintenance"> <option value = "Yes" <?php if ($_POST['maintenance'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['maintenance'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "maintenance"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Hangarage?</td> <td> <select name = "hangarage"> <option value = "Yes" <?php if ($_POST['hangarage'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['hangarage'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "hangarage"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Parking?</td> <td> <select name = "parking"> <option value = "Yes" <?php if ($_POST['parking'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['parking'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "parking"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Accommodation?</td> <td> <select name = "accommodation"> <option value = "Yes" <?php if ($_POST['accommodation'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['accommodation'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "accommodation"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>School?</td> <td> <select name = "school"> <option value = "Flexwing" <?php if ($_POST['school'] == 'Flexwing') { echo 'selected="selected"'; } ?>>Flexwing</option> <option value="3 Axis" <?php if ($_POST['school'] == '3 Axis') { echo 'selected="selected"'; } ?>>3 Axis</option> <option value = "All Microlight" <?php if ($_POST['school'] == 'All Microlight') { echo 'selected="selected"'; } ?>>All Microlight</option> <option value="GA" <?php if ($_POST['school'] == 'GA') { echo 'selected="selected"'; } ?>>GA</option> <option value="Gyro" <?php if ($_POST['school'] == 'Gyro') { echo 'selected="selected"'; } ?>>Gyro</option> <option value="Microlight and Gyro" <?php if ($_POST['school'] == 'Microlight and Gyro') { echo 'selected="selected"'; } ?>>Microlight and Gyro</option> <option value="Other See Comments" <?php if ($_POST['school'] == 'Other See Comments') { echo 'selected="selected"'; } ?>>Other See Comments</option> </select> <!--<select name = "school"> <option value = "Flexwing">Flexwing </option> <option value="3 Axis">3 Axis</option> <option value="All Microlight">All Mircolight</option> <option value="GA">GA</option> <option value="Gyro">Gyro</option> <option value="Other See Remarks">Other, See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Remarks:</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Warnings:</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Web Links</td> <td><textarea name= "weblinks" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $weblinks; ?></textarea></td> <td>Link to airfield website</td> </tr> <tr> <td> </td> <td>Operator Details</td> <td><textarea name= "operator" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $operator; ?></textarea></td> <td>As much info as possible</td> </tr> <tr> <td> </td> <td>Google Iframe Image</td> <td><textarea name= "google_image" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $google_image; ?></textarea></td> <td>700 x 700 pixels please. <a href="http://www.youtube.com/watch?v=gVRWhLEvt-I" target = "_blank">Watch Video here for How to Get the Image from Google</a></td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "mypublickey"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?>
  2. Hi TeNDoLLA. Thanks for your input. I have changed it as you have said but nothing has changed on the site. See http://microlight.co/index.php/huddersfield Any ideas?
  3. Hi Mate, thanks for your input. I've tried and better tried to get it to work but failed. Please could you tell me exactly what to put into the following output I have on my site. <p><strong><? echo $rs ["operator"]; ?></strong></p></td> The output on the site http://microlight.co/index.php/huddersfield currently looks like this Operator: J Whitham\r\nHuddersfield Aviation Ltd\r\nThe Airfield\r\nCrossland Moor\r\nHD4 7AG\r\n01484 645784 When it should look like this... Operator: J Whitham Huddersfield Aviation Ltd The Airfield Crossland Moor HD4 7AG 01484 645784
  4. Hi people. I have some \r\n characters in my database, but there by user input of the enter key to go to the next line. However, in my output form I get the \r\n character instead of the desired effect. Please could you tell me what I need to add, and to where in my output box to get it to show correctly. I don't want it to be removed from the DB obviously because the line breaks won't be there. <?php $host = 'localhost'; $usr = "DatabaseUsername"; $password = 'thepassword'; $db_name = 'DataBaseName'; $id = 19; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from users where user_id = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!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>Untitled Document</title> </head> <body> Airfield Name: <? echo $rs["username"]; ?> <table width="720" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="5"> <tr> <td width="120" bgcolor = #E6F8EB>Height Above MSL</td> <td width="120" bgcolor = #E6F8EB>Mb Difference</td> <td width="120" bgcolor = #E6F8EB>Alternative</td> <td width="120" bgcolor = #E6F8EB>PPR?</td> <td width="120" bgcolor = #E6F8EB>Location General</td> <td width="120" bgcolor = #E6F8EB>Location Grid Ref:</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["height_above"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["mb_diff"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["alternative"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["ppr"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["general_location"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location_grid"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Runway Numbers</td> <td bgcolor = #dbeff8>Circuit Direction</td> <td bgcolor = #dbeff8>Circuit Height</td> <td bgcolor = #dbeff8>Runway Length</td> <td bgcolor = #dbeff8>Runway Surface</td> <td bgcolor = #dbeff8>Food? </td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["runway_numbers"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["circuit_direction"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["circuit_height"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["runway_length"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["surface"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["food"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Radio Frequency</td> <td bgcolor = #E6F8EB>Radio Callsign</td> <td bgcolor = #E6F8EB>Radio Type</td> <td bgcolor = #E6F8EB>Other Radio</td> <td bgcolor = #E6F8EB>Fuel?</td> <td bgcolor = #E6F8EB>Landing Fee £</td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_frequency"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_type"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["other_radio"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["fuel"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["landing_fee"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Opperating Hrs</td> <td bgcolor = #dbeff8>Maintenance</td> <td bgcolor = #dbeff8>Hangarage</td> <td bgcolor = #dbeff8>Parking</td> <td bgcolor = #dbeff8>Accommodation</td> <td bgcolor = #dbeff8>School ?</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["operating_hours"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["maintenance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["hangarage"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["parking"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["accommodation"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["school"]; ?></strong></td> </tr> <tr> <td colspan="6"><p>Remarks<p><strong><? echo $rs["remarks"]; ?></strong></td> </tr> <tr> <td colspan="6"><p>Warnings:</p> <p><strong><? echo $rs["warnings"]; ?></strong></p> <p> </p></td> </tr> <tr> <td colspan="3"><p>Website: </p> <p><strong><? echo $rs["weblinks"]; ?></strong></p></td> <td colspan="3"><p>Operator:</p> <p><strong><? echo $rs["operator"]; ?></strong></p></td> </tr> <tr> <td colspan="6">Google Ifram Image<br /><strong><? echo $rs["google_image"]; ?></strong></td> </tr> </table> </body> </html> </html>
  5. Hi People. I have a form in which users input airfield information, however I have a problem in that I sometimes get \r\n characters in the database and these show up in the finished form. Please could you tell me what is causing this, and how to fix it. Here is a copy of my code. The site is live and I have to edit the database after each time someone has done the inserting. <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "VinnyG"; $password = 'thepassword'; $db_name = 'sitename'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $username = mysql_real_escape_string($_POST['username']); $height_above = mysql_real_escape_string($_POST['height_above']); $mb_diff = mysql_real_escape_string($_POST['mb_diff']); $alternative = mysql_real_escape_string($_POST['alternative']); $ppr = mysql_real_escape_string($_POST['ppr']); $general_location = mysql_real_escape_string($_POST['general_location']); $location_grid = mysql_real_escape_string($_POST['location_grid']); $runway_numbers = mysql_real_escape_string($_POST['runway_numbers']); $circuit_direction = mysql_real_escape_string($_POST['circuit_direction']); $circuit_height = mysql_real_escape_string($_POST['circuit_height']); $runway_length = mysql_real_escape_string($_POST['runway_length']); $surface = mysql_real_escape_string($_POST['surface']); $food = mysql_real_escape_string($_POST['food']); $radio_frequency = mysql_real_escape_string($_POST['radio_frequency']); $radio_callsign = mysql_real_escape_string($_POST['radio_callsign']); $radio_type = mysql_real_escape_string($_POST['radio_type']); $other_radio = mysql_real_escape_string($_POST['other_radio']); $fuel = mysql_real_escape_string($_POST['fuel']); $landing_fee = mysql_real_escape_string($_POST['landing_fee']); $operating_hours = mysql_real_escape_string($_POST['operating_hours']); $maintenance = mysql_real_escape_string($_POST['maintenance']); $hangarage = mysql_real_escape_string($_POST['hangarage']); $parking = mysql_real_escape_string($_POST['parking']); $accommodation = mysql_real_escape_string($_POST['accommodation']); $school = mysql_real_escape_string($_POST['school']); $remarks = mysql_real_escape_string($_POST['remarks']); $warnings = mysql_real_escape_string($_POST['warnings']); $weblinks = mysql_real_escape_string($_POST['weblinks']); $operator = mysql_real_escape_string($_POST['operator']); $google_image = mysql_real_escape_string($_POST['google_image']); $errorstring = ""; // default value of errorstring if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "my Private Capcha Key"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($username =="") $errorstring = $errorstring. "Airfield Name<br>"; if ($height_above =="") $errorstring = $errorstring. "Height Above Mean Sea Level<br>"; if ($mb_diff =="") $errorstring = $errorstring. "mb Difference<br>"; if ($alternative =="") $errorstring = $errorstring. "Alternative Airfield<br>"; if ($general_location =="") $errorstring = $errorstring. "General Location<br>"; if ($location_grid =="") $errorstring = $errorstring. "Grid Reference<br>"; if ($runway_numbers =="") $errorstring = $errorstring. "Runway Numbers<br>"; if ($circuit_direction =="") $errorstring = $errorstring. "Circuit Direction<br>"; if ($circuit_height =="") $errorstring = $errorstring. "Circuit Height<br>"; if ($runway_length =="") $errorstring = $errorstring. "Runway Length<br>"; if ($radio_frequency =="") $errorstring = $errorstring. "Radio Frequency<br>"; if ($radio_callsign =="") $errorstring = $errorstring. "Radio Callsign<br>"; if ($other_radio =="") $errorstring = $errorstring. "Other Radio<br>"; if ($landing_fee =="") $errorstring = $errorstring. "Landing Fee<br>"; if ($remarks =="") $errorstring = $errorstring. "Remarks<br>"; if ($warnings =="") $errorstring = $errorstring. "Warnings<br>"; if ($weblinks =="") $errorstring = $errorstring. "Web Links<br>"; if ($operator =="") $errorstring = $errorstring. "Operator<br>"; if ($google_image =="") $errorstring = $errorstring. "Google Image<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; $insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr, general_location, location_grid, runway_numbers, circuit_direction, circuit_height, runway_length, surface, food, radio_frequency, radio_callsign, radio_type, other_radio, fuel, landing_fee, operating_hours, maintenance, hangarage, parking, accommodation, school, remarks, warnings, weblinks, operator, google_image) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr', '$general_location', '$location_grid', '$runway_numbers', '$circuit_direction', '$circuit_height', '$runway_length', '$surface', '$food', '$radio_frequency', '$radio_callsign', '$radio_type', '$other_radio', '$fuel', '$landing_fee', '$operating_hours', '$maintenance', '$hangarage', '$parking', '$accommodation' , '$school', '$remarks', '$warnings', '$weblinks', '$operator', '$google_image')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your airfield has been submitted."; include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#c9e1d0"> <caption> Submit Your Airfield Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Airfield Name</td> <td><input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'></td> <td>Ince Blundell</td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above' size = '40' maxlength= '30'value = '<?php echo $height_above; ?>'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'value = '<?php echo $mb_diff; ?>'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td> <select name = "ppr"> <option value = "Yes" <?php if ($_POST['ppr'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['ppr'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>General Location</td> <td><input type='text' name='general_location' size = '40' maxlength='50' value = '<?php echo $general_location; ?>' /></td> <td>3 Nm North Luton</td> </tr> <tr> <td> </td> <td>Location Grid Reference</td> <td><textarea name= "location_grid" input type = 'text' rows = "2" cols = "29" /><?php echo $location_grid; ?></textarea></td> <td> 53°57'7.68"N<br /> 1°10'30.33"W</td> </tr> <tr> <td> </td> <td>Runway Numbers</td> <td><textarea name= "runway_numbers" input type = 'text' rows = "5" cols = "29" /><?php echo $runway_numbers; ?></textarea></td> <td><p>This format please<br /> 05-23<br /> 18-36<br /> 14-22 </p></td> </tr> <tr> <td> </td> <td>Circuit Direction</td> <td><textarea name= "circuit_direction" input type = "text" rows = "5" cols = "29" /><?php echo $circuit_direction; ?></textarea></td> <td><p>05-LH<br /> 23-RH<br /> 14-LH </p></td> </tr> <tr> <td> </td> <td>Circuit Height</td> <td><input type='text' name='circuit_height' size = '40' maxlength='50' value = '<?php echo $circuit_height; ?>' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' value = '<?php echo $runway_length; ?>' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td> <select name = "surface"> <option value = "Grass" <?php if ($_POST['surface'] == 'Grass') { echo 'selected="selected"'; } ?>>Grass</option> <option value = "Tarmac" <?php if ($_POST['surface'] == 'Tarmac') { echo 'selected="selected"'; } ?>>Tarmac</option> <option value = "Concrete" <?php if ($_POST['surface'] == 'Concrete') { echo 'selected="selected"'; } ?>>Concrete</option> <option value = "Dirt" <?php if ($_POST['surface'] == 'Dirt') { echo 'selected="selected"'; } ?>>Dirt</option> </select> <!-- <select name = "surface"> <option value = "Grass">Grass</option> <option value="Tarmac">Tarmac</option> <option value ="Concrete">Concrete</option> <option value = "Dirt">Dirt</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Food?</td> <td> <select name = "food"> <option value = "Cafe" <?php if ($_POST['food'] == 'Cafe') { echo 'selected="selected"'; } ?>>Cafe</option> <option value = "None" <?php if ($_POST['food'] == 'None') { echo 'selected="selected"'; } ?>>None</option> <option value = "Tea and Coffee" <?php if ($_POST['food'] == 'Tea and Coffee') { echo 'selected="selected"'; } ?>>Tea and Coffee</option> <option value = "Make Your Own" <?php if ($_POST['food'] == 'Make Your Own') { echo 'selected="selected"'; } ?>>Make Your Own</option> </select> <!-- <select name = "food"> <option value = "Cafe">Cafe</option> <option value="None">None</option> <option value ="Tea and Coffee">Tea and Coffee</option> <option value = "Make Your Own">Make Your Own</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Radio Frequency</td> <td><input type='text' name='radio_frequency' size = '40'maxlength='50' value = '<?php echo $radio_frequency; ?>' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' value = '<?php echo $radio_callsign; ?>' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td> <select name = "radio_type"> <option value = "Safety Com" <?php if ($_POST['radio_type'] == 'Safety Com') { echo 'selected="selected"'; } ?>>Safety Com</option> <option value = "Air Ground" <?php if ($_POST['radio_type'] == 'Air Ground') { echo 'selected="selected"'; } ?>>Air Ground</option> <option value = "Approach" <?php if ($_POST['radio_type'] == 'Approach') { echo 'selected="selected"'; } ?>>Approach</option> <option value = "Tower" <?php if ($_POST['radio_type'] == 'Tower') { echo 'selected="selected"'; } ?>>Tower</option> </select> <!-- <select name = "radio_type"> <option value = "Sefety Com">Safety Com</option> <option value="Air Ground">Air Ground</option> <option value ="Approach">Approach</option> <option value = "Tower">Tower</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Other Radio</td> <td><input type='text' name='other_radio' size = '40' maxlength='50' value = '<?php echo $other_radio; ?>' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td> <select name = "fuel"> <option value = "AvGas" <?php if ($_POST['fuel'] == 'AvGas') { echo 'selected="selected"'; } ?>>AvGas</option> <option value = "MoGas" <?php if ($_POST['fuel'] == 'MoGas') { echo 'selected="selected"'; } ?>>MoGas</option> <option value = "AvGas and MoGas" <?php if ($_POST['fuel'] == 'AvGas and MoGas') { echo 'selected="selected"'; } ?>>AvGas and MoGas</option> <option value = "We will sort you some" <?php if ($_POST['fuel'] == 'We will sort you some') { echo 'selected="selected"'; } ?>>We will sort you some</option> <option value = "None" <?php if ($_POST['fuel'] == 'None') { echo 'selected="selected"'; } ?>>None</option> </select> <!-- <select name = "fuel"> <option value = "AvGas">AvGas</option> <option value="MoGas">MoGas</option> <option value ="AvGas and MoGas">AvGas and MoGas</option> <option value = "We will sort you some">We will sort you some</option> <option value = "None">None</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Landing Fee</td> <td><input type='text' name='landing_fee' size = '40' maxlength='50' value = '<?php echo $landing_fee; ?>' /></td> <td>£ or Nill </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td> <select name = "operating_hours"> <option value = "SR - SS" <?php if ($_POST['operating_hours'] == 'SR - SS') { echo 'selected="selected"'; } ?>>SR - SS</option> <option value="Other - See Remarks" <?php if ($_POST['operating_hours'] == 'Other - See Remarks') { echo 'selected="selected"'; } ?>>Other - See Remarks</option> </select> <!-- <select name = "operating_hours"> <option value = "SR - SS">Sunrise - Sunset</option> <option value="See Remarks">Other - See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Maintenance?</td> <td> <select name = "maintenance"> <option value = "Yes" <?php if ($_POST['maintenance'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['maintenance'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "maintenance"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Hangarage?</td> <td> <select name = "hangarage"> <option value = "Yes" <?php if ($_POST['hangarage'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['hangarage'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "hangarage"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Parking?</td> <td> <select name = "parking"> <option value = "Yes" <?php if ($_POST['parking'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['parking'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "parking"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Accommodation?</td> <td> <select name = "accommodation"> <option value = "Yes" <?php if ($_POST['accommodation'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['accommodation'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "accommodation"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>School?</td> <td> <select name = "school"> <option value = "Flexwing" <?php if ($_POST['school'] == 'Flexwing') { echo 'selected="selected"'; } ?>>Flexwing</option> <option value="3 Axis" <?php if ($_POST['school'] == '3 Axis') { echo 'selected="selected"'; } ?>>3 Axis</option> <option value = "All Microlight" <?php if ($_POST['school'] == 'All Microlight') { echo 'selected="selected"'; } ?>>All Microlight</option> <option value="GA" <?php if ($_POST['school'] == 'GA') { echo 'selected="selected"'; } ?>>GA</option> <option value="Gyro" <?php if ($_POST['school'] == 'Gyro') { echo 'selected="selected"'; } ?>>Gyro</option> <option value="Microlight and Gyro" <?php if ($_POST['school'] == 'Microlight and Gyro') { echo 'selected="selected"'; } ?>>Microlight and Gyro</option> <option value="Other See Comments" <?php if ($_POST['school'] == 'Other See Comments') { echo 'selected="selected"'; } ?>>Other See Comments</option> </select> <!--<select name = "school"> <option value = "Flexwing">Flexwing </option> <option value="3 Axis">3 Axis</option> <option value="All Microlight">All Mircolight</option> <option value="GA">GA</option> <option value="Gyro">Gyro</option> <option value="Other See Remarks">Other, See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Remarks:</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Warnings:</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Web Links</td> <td><textarea name= "weblinks" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $weblinks; ?></textarea></td> <td>Link to airfield website</td> </tr> <tr> <td> </td> <td>Operator Details</td> <td><textarea name= "operator" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $operator; ?></textarea></td> <td>As much info as possible</td> </tr> <tr> <td> </td> <td>Google Iframe Image</td> <td><textarea name= "google_image" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $google_image; ?></textarea></td> <td>700 x 700 pixels please. <a href="http://www.youtube.com/watch?v=gVRWhLEvt-I" target = "_blank">Watch Video here for How to Get the Image from Google</a></td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "6LchDMQSAAAAAEzBqGRGI8-JpR2It6apJw9kVOqC"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?>
  6. Hi Mate. I've just tried re-naming it, uploaded to my server and now it works. I must have had the old one in my browser cashe Thanks again. Sorted.
  7. I only tried it with the first one. Just to see if I got the error code empty again.
  8. Just done that, see the code. Still the same, not installing the info. Get the "you have not put anything in the box error. <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "VinnyG"; $password = 'thepassword'; $db_name = 'sitename'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $username = mysql_real_escape_string($_POST['username']); $height_above = mysql_real_escape_string($_POST['height_above']); $mb_diff = mysql_real_escape_string($_POST['mb_diff']); $alternative = mysql_real_escape_string($_POST['alternative']); $ppr = mysql_real_escape_string($_POST['ppr']); $general_location = mysql_real_escape_string($_POST['general_location']); $location_grid = mysql_real_escape_string($_POST['location_grid']); $runway_numbers = mysql_real_escape_string($_POST['runway_numbers']); $circuit_direction = mysql_real_escape_string($_POST['circuit_direction']); $circuit_height = mysql_real_escape_string($_POST['circuit_height']); $runway_length = mysql_real_escape_string($_POST['runway_length']); $surface = mysql_real_escape_string($_POST['surface']); $food = mysql_real_escape_string($_POST['food']); $radio_frequency = mysql_real_escape_string($_POST['radio_frequency']); $radio_callsign = mysql_real_escape_string($_POST['radio_callsign']); $radio_type = mysql_real_escape_string($_POST['radio_type']); $other_radio = mysql_real_escape_string($_POST['other_radio']); $fuel = mysql_real_escape_string($_POST['fuel']); $landing_fee = mysql_real_escape_string($_POST['landing_fee']); $operating_hours = mysql_real_escape_string($_POST['operating_hours']); $maintenance = mysql_real_escape_string($_POST['maintenance']); $hangarage = mysql_real_escape_string($_POST['hangarage']); $parking = mysql_real_escape_string($_POST['parking']); $accommodation = mysql_real_escape_string($_POST['accommodation']); $school = mysql_real_escape_string($_POST['school']); $remarks = mysql_real_escape_string($_POST['remarks']); $warnings = mysql_real_escape_string($_POST['warnings']); $weblinks = mysql_real_escape_string($_POST['weblinks']); $operator = mysql_real_escape_string($_POST['operator']); $google_image = mysql_real_escape_string($_POST['google_image']); $errorstring = ""; // default value of errorstring if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "Private Key Goes Here"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($username =="") $errorstring = $errorstring. "Airfield Name<br>"; if ($height_above =="") $errorstring = $errorstring. "Height Above Mean Sea Level<br>"; if ($mb_diff =="") $errorstring = $errorstring. "mb Difference<br>"; if ($alternative =="") $errorstring = $errorstring. "Alternative Airfield<br>"; if ($general_location =="") $errorstring = $errorstring. "General Location<br>"; if ($location_grid =="") $errorstring = $errorstring. "Grid Reference<br>"; if ($runway_numbers =="") $errorstring = $errorstring. "Runway Numbers<br>"; if ($circuit_direction =="") $errorstring = $errorstring. "Circuit Direction<br>"; if ($circuit_height =="") $errorstring = $errorstring. "Circuit Height<br>"; if ($runway_length =="") $errorstring = $errorstring. "Runway Length<br>"; if ($radio_frequency =="") $errorstring = $errorstring. "Radio Frequency<br>"; if ($radio_callsign =="") $errorstring = $errorstring. "Radio Callsign<br>"; if ($other_radio =="") $errorstring = $errorstring. "Other Radio<br>"; if ($landing_fee =="") $errorstring = $errorstring. "Landing Fee<br>"; if ($remarks =="") $errorstring = $errorstring. "Remarks<br>"; if ($warnings =="") $errorstring = $errorstring. "Warnings<br>"; if ($weblinks =="") $errorstring = $errorstring. "Web Links<br>"; if ($operator =="") $errorstring = $errorstring. "Operator<br>"; if ($google_image =="") $errorstring = $errorstring. "Google Image<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; $insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr, general_location, location_grid, runway_numbers, circuit_direction, circuit_height, runway_length, surface, food, radio_frequency, radio_callsign, radio_type, other_radio, fuel, landing_fee, operating_hours, maintenance, hangarage, parking, accommodation, school, remarks, warnings, weblinks, operator, google_image) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr', '$general_location', '$location_grid', '$runway_numbers', '$circuit_direction', '$circuit_height', '$runway_length', '$surface', '$food', '$radio_frequency', '$radio_callsign', '$radio_type', '$other_radio', '$fuel', '$landing_fee', '$operating_hours', '$maintenance', '$hangarage', '$parking', '$accommodation' , '$school', '$remarks', '$warnings', '$weblinks', '$operator', '$google_image')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your airfield has been submitted."; include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#c9e1d0"> <caption> Submit Your Airfield Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Airfield Name</td> <td><input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'></td> <td>Ince Blundell</td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above' size = '40' maxlength= '30'value = '<?php echo $height_above; ?>'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'value = '<?php echo $mb_diff; ?>'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td> <select name = "ppr"> <option value = "Yes" <?php if ($_POST['ppr'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['ppr'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>General Location</td> <td><input type='text' name='general_location' size = '40' maxlength='50' value = '<?php echo $general_location; ?>' /></td> <td>3 Nm North Luton</td> </tr> <tr> <td> </td> <td>Location Grid Reference</td> <td><textarea name= "location_grid" input type = 'text' rows = "2" cols = "29" /><?php echo $location_grid; ?></textarea></td> <td> 53°57'7.68"N<br /> 1°10'30.33"W</td> </tr> <tr> <td> </td> <td>Runway Numbers</td> <td><textarea name= "runway_numbers" input type = 'text' rows = "5" cols = "29" /><?php echo $runway_numbers; ?></textarea></td> <td><p>This format please<br /> 05-23<br /> 18-36<br /> 14-22 </p></td> </tr> <tr> <td> </td> <td>Circuit Direction</td> <td><textarea name= "circuit_direction" input type = "text" rows = "5" cols = "29" /><?php echo $circuit_direction; ?></textarea></td> <td><p>05-LH<br /> 23-RH<br /> 14-LH </p></td> </tr> <tr> <td> </td> <td>Circuit Height</td> <td><input type='text' name='circuit_height' size = '40' maxlength='50' value = '<?php echo $circuit_height; ?>' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' value = '<?php echo $runway_length; ?>' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td> <select name = "surface"> <option value = "Grass" <?php if ($_POST['surface'] == 'Grass') { echo 'selected="selected"'; } ?>>Grass</option> <option value = "Tarmac" <?php if ($_POST['surface'] == 'Tarmac') { echo 'selected="selected"'; } ?>>Tarmac</option> <option value = "Concrete" <?php if ($_POST['surface'] == 'Concrete') { echo 'selected="selected"'; } ?>>Concrete</option> <option value = "Dirt" <?php if ($_POST['surface'] == 'Dirt') { echo 'selected="selected"'; } ?>>Dirt</option> </select> <!-- <select name = "surface"> <option value = "Grass">Grass</option> <option value="Tarmac">Tarmac</option> <option value ="Concrete">Concrete</option> <option value = "Dirt">Dirt</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Food?</td> <td> <select name = "food"> <option value = "Cafe" <?php if ($_POST['food'] == 'Cafe') { echo 'selected="selected"'; } ?>>Cafe</option> <option value = "None" <?php if ($_POST['food'] == 'None') { echo 'selected="selected"'; } ?>>None</option> <option value = "Tea and Coffee" <?php if ($_POST['food'] == 'Tea and Coffee') { echo 'selected="selected"'; } ?>>Tea and Coffee</option> <option value = "Make Your Own" <?php if ($_POST['food'] == 'Make Your Own') { echo 'selected="selected"'; } ?>>Make Your Own</option> </select> <!-- <select name = "food"> <option value = "Cafe">Cafe</option> <option value="None">None</option> <option value ="Tea and Coffee">Tea and Coffee</option> <option value = "Make Your Own">Make Your Own</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Radio Frequency</td> <td><input type='text' name='radio_frequency' size = '40'maxlength='50' value = '<?php echo $radio_frequency; ?>' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' value = '<?php echo $radio_callsign; ?>' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td> <select name = "radio_type"> <option value = "Safety Com" <?php if ($_POST['radio_type'] == 'Safety Com') { echo 'selected="selected"'; } ?>>Safety Com</option> <option value = "Air Ground" <?php if ($_POST['radio_type'] == 'Air Ground') { echo 'selected="selected"'; } ?>>Air Ground</option> <option value = "Approach" <?php if ($_POST['radio_type'] == 'Approach') { echo 'selected="selected"'; } ?>>Approach</option> <option value = "Tower" <?php if ($_POST['radio_type'] == 'Tower') { echo 'selected="selected"'; } ?>>Tower</option> </select> <!-- <select name = "radio_type"> <option value = "Sefety Com">Safety Com</option> <option value="Air Ground">Air Ground</option> <option value ="Approach">Approach</option> <option value = "Tower">Tower</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Other Radio</td> <td><input type='text' name='other_radio' size = '40' maxlength='50' value = '<?php echo $other_radio; ?>' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td> <select name = "fuel"> <option value = "AvGas" <?php if ($_POST['fuel'] == 'AvGas') { echo 'selected="selected"'; } ?>>AvGas</option> <option value = "MoGas" <?php if ($_POST['fuel'] == 'MoGas') { echo 'selected="selected"'; } ?>>MoGas</option> <option value = "AvGas and MoGas" <?php if ($_POST['fuel'] == 'AvGas and MoGas') { echo 'selected="selected"'; } ?>>AvGas and MoGas</option> <option value = "We will sort you some" <?php if ($_POST['fuel'] == 'We will sort you some') { echo 'selected="selected"'; } ?>>We will sort you some</option> <option value = "None" <?php if ($_POST['fuel'] == 'None') { echo 'selected="selected"'; } ?>>None</option> </select> <!-- <select name = "fuel"> <option value = "AvGas">AvGas</option> <option value="MoGas">MoGas</option> <option value ="AvGas and MoGas">AvGas and MoGas</option> <option value = "We will sort you some">We will sort you some</option> <option value = "None">None</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Landing Fee</td> <td><input type='text' name='landing_fee' size = '40' maxlength='50' value = '<?php echo $landing_fee; ?>' /></td> <td>£ or Nill </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td> <select name = "operating_hours"> <option value = "SR - SS" <?php if ($_POST['operating_hours'] == 'SR - SS') { echo 'selected="selected"'; } ?>>SR - SS</option> <option value="Other - See Remarks" <?php if ($_POST['operating_hours'] == 'Other - See Remarks') { echo 'selected="selected"'; } ?>>Other - See Remarks</option> </select> <!-- <select name = "operating_hours"> <option value = "SR - SS">Sunrise - Sunset</option> <option value="See Remarks">Other - See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Maintenance?</td> <td> <select name = "maintenance"> <option value = "Yes" <?php if ($_POST['maintenance'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['maintenance'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "maintenance"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Hangarage?</td> <td> <select name = "hangarage"> <option value = "Yes" <?php if ($_POST['hangarage'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['hangarage'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "hangarage"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Parking?</td> <td> <select name = "parking"> <option value = "Yes" <?php if ($_POST['parking'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['parking'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "parking"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Accommodation?</td> <td> <select name = "accommodation"> <option value = "Yes" <?php if ($_POST['accommodation'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['accommodation'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "accommodation"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>School?</td> <td> <select name = "school"> <option value = "Flexwing" <?php if ($_POST['school'] == 'Flexwing') { echo 'selected="selected"'; } ?>>Flexwing</option> <option value="3 Axis" <?php if ($_POST['school'] == '3 Axis') { echo 'selected="selected"'; } ?>>3 Axis</option> <option value = "All Microlight" <?php if ($_POST['school'] == 'All Microlight') { echo 'selected="selected"'; } ?>>All Microlight</option> <option value="GA" <?php if ($_POST['school'] == 'GA') { echo 'selected="selected"'; } ?>>GA</option> <option value="Gyro" <?php if ($_POST['school'] == 'Gyro') { echo 'selected="selected"'; } ?>>Gyro</option> <option value="Microlight and Gyro" <?php if ($_POST['school'] == 'Microlight and Gyro') { echo 'selected="selected"'; } ?>>Microlight and Gyro</option> <option value="Other See Comments" <?php if ($_POST['school'] == 'Other See Comments') { echo 'selected="selected"'; } ?>>Other See Comments</option> </select> <!--<select name = "school"> <option value = "Flexwing">Flexwing </option> <option value="3 Axis">3 Axis</option> <option value="All Microlight">All Mircolight</option> <option value="GA">GA</option> <option value="Gyro">Gyro</option> <option value="Other See Remarks">Other, See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Remarks:</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Warnings:</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Web Links</td> <td><textarea name= "weblinks" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $weblinks; ?></textarea></td> <td>Link to airfield website</td> </tr> <tr> <td> </td> <td>Operator Details</td> <td><textarea name= "operator" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $operator; ?></textarea></td> <td>As much info as possible</td> </tr> <tr> <td> </td> <td>Google Iframe Image</td> <td><textarea name= "google_image" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $google_image; ?></textarea></td> <td>700 x 700 pixels please. <a href="http://www.youtube.com/watch?v=gVRWhLEvt-I" target = "_blank">Watch Video here for How to Get the Image from Google</a></td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "Public Key Goes Here"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?>
  9. I've done that as you said and it now doesn't work. I get the errors saying that I haven't added any input. <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "VinnyG"; $password = 'thepassword'; $db_name = 'sitename'; $username = mysql_real_escape_string($_POST['username']); $height_above = mysql_real_escape_string($_POST['height_above']); $mb_diff = mysql_real_escape_string($_POST['mb_diff']); $alternative = mysql_real_escape_string($_POST['alternative']); $ppr = mysql_real_escape_string($_POST['ppr']); $general_location = mysql_real_escape_string($_POST['general_location']); $location_grid = mysql_real_escape_string($_POST['location_grid']); $runway_numbers = mysql_real_escape_string($_POST['runway_numbers']); $circuit_direction = mysql_real_escape_string($_POST['circuit_direction']); $circuit_height = mysql_real_escape_string($_POST['circuit_height']); $runway_length = mysql_real_escape_string($_POST['runway_length']); $surface = mysql_real_escape_string($_POST['surface']); $food = mysql_real_escape_string($_POST['food']); $radio_frequency = mysql_real_escape_string($_POST['radio_frequency']); $radio_callsign = mysql_real_escape_string($_POST['radio_callsign']); $radio_type = mysql_real_escape_string($_POST['radio_type']); $other_radio = mysql_real_escape_string($_POST['other_radio']); $fuel = mysql_real_escape_string($_POST['fuel']); $landing_fee = mysql_real_escape_string($_POST['landing_fee']); $operating_hours = mysql_real_escape_string($_POST['operating_hours']); $maintenance = mysql_real_escape_string($_POST['maintenance']); $hangarage = mysql_real_escape_string($_POST['hangarage']); $parking = mysql_real_escape_string($_POST['parking']); $accommodation = mysql_real_escape_string($_POST['accommodation']); $school = mysql_real_escape_string($_POST['school']); $remarks = mysql_real_escape_string($_POST['remarks']); $warnings = mysql_real_escape_string($_POST['warnings']); $weblinks = mysql_real_escape_string($_POST['weblinks']); $operator = mysql_real_escape_string($_POST['operator']); $google_image = mysql_real_escape_string($_POST['google_image']); $errorstring = ""; // default value of errorstring if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "//private key entered here"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($username =="") $errorstring = $errorstring. "Airfield Name<br>"; if ($height_above =="") $errorstring = $errorstring. "Height Above Mean Sea Level<br>"; if ($mb_diff =="") $errorstring = $errorstring. "mb Difference<br>"; if ($alternative =="") $errorstring = $errorstring. "Alternative Airfield<br>"; if ($general_location =="") $errorstring = $errorstring. "General Location<br>"; if ($location_grid =="") $errorstring = $errorstring. "Grid Reference<br>"; if ($runway_numbers =="") $errorstring = $errorstring. "Runway Numbers<br>"; if ($circuit_direction =="") $errorstring = $errorstring. "Circuit Direction<br>"; if ($circuit_height =="") $errorstring = $errorstring. "Circuit Height<br>"; if ($runway_length =="") $errorstring = $errorstring. "Runway Length<br>"; if ($radio_frequency =="") $errorstring = $errorstring. "Radio Frequency<br>"; if ($radio_callsign =="") $errorstring = $errorstring. "Radio Callsign<br>"; if ($other_radio =="") $errorstring = $errorstring. "Other Radio<br>"; if ($landing_fee =="") $errorstring = $errorstring. "Landing Fee<br>"; if ($remarks =="") $errorstring = $errorstring. "Remarks<br>"; if ($warnings =="") $errorstring = $errorstring. "Warnings<br>"; if ($weblinks =="") $errorstring = $errorstring. "Web Links<br>"; if ($operator =="") $errorstring = $errorstring. "Operator<br>"; if ($google_image =="") $errorstring = $errorstring. "Google Image<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr, general_location, location_grid, runway_numbers, circuit_direction, circuit_height, runway_length, surface, food, radio_frequency, radio_callsign, radio_type, other_radio, fuel, landing_fee, operating_hours, maintenance, hangarage, parking, accommodation, school, remarks, warnings, weblinks, operator, google_image) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr', '$general_location', '$location_grid', '$runway_numbers', '$circuit_direction', '$circuit_height', '$runway_length', '$surface', '$food', '$radio_frequency', '$radio_callsign', '$radio_type', '$other_radio', '$fuel', '$landing_fee', '$operating_hours', '$maintenance', '$hangarage', '$parking', '$accommodation' , '$school', '$remarks', '$warnings', '$weblinks', '$operator', '$google_image')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your airfield has been submitted."; include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#c9e1d0"> <caption> Submit Your Airfield Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Airfield Name</td> <td><input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'></td> <td>Ince Blundell</td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above' size = '40' maxlength= '30'value = '<?php echo $height_above; ?>'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'value = '<?php echo $mb_diff; ?>'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td> <select name = "ppr"> <option value = "Yes" <?php if ($_POST['ppr'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['ppr'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>General Location</td> <td><input type='text' name='general_location' size = '40' maxlength='50' value = '<?php echo $general_location; ?>' /></td> <td>3 Nm North Luton</td> </tr> <tr> <td> </td> <td>Location Grid Reference</td> <td><textarea name= "location_grid" input type = 'text' rows = "2" cols = "29" /><?php echo $location_grid; ?></textarea></td> <td> 53°57'7.68"N<br /> 1°10'30.33"W</td> </tr> <tr> <td> </td> <td>Runway Numbers</td> <td><textarea name= "runway_numbers" input type = 'text' rows = "5" cols = "29" /><?php echo $runway_numbers; ?></textarea></td> <td><p>This format please<br /> 05-23<br /> 18-36<br /> 14-22 </p></td> </tr> <tr> <td> </td> <td>Circuit Direction</td> <td><textarea name= "circuit_direction" input type = "text" rows = "5" cols = "29" /><?php echo $circuit_direction; ?></textarea></td> <td><p>05-LH<br /> 23-RH<br /> 14-LH </p></td> </tr> <tr> <td> </td> <td>Circuit Height</td> <td><input type='text' name='circuit_height' size = '40' maxlength='50' value = '<?php echo $circuit_height; ?>' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' value = '<?php echo $runway_length; ?>' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td> <select name = "surface"> <option value = "Grass" <?php if ($_POST['surface'] == 'Grass') { echo 'selected="selected"'; } ?>>Grass</option> <option value = "Tarmac" <?php if ($_POST['surface'] == 'Tarmac') { echo 'selected="selected"'; } ?>>Tarmac</option> <option value = "Concrete" <?php if ($_POST['surface'] == 'Concrete') { echo 'selected="selected"'; } ?>>Concrete</option> <option value = "Dirt" <?php if ($_POST['surface'] == 'Dirt') { echo 'selected="selected"'; } ?>>Dirt</option> </select> <!-- <select name = "surface"> <option value = "Grass">Grass</option> <option value="Tarmac">Tarmac</option> <option value ="Concrete">Concrete</option> <option value = "Dirt">Dirt</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Food?</td> <td> <select name = "food"> <option value = "Cafe" <?php if ($_POST['food'] == 'Cafe') { echo 'selected="selected"'; } ?>>Cafe</option> <option value = "None" <?php if ($_POST['food'] == 'None') { echo 'selected="selected"'; } ?>>None</option> <option value = "Tea and Coffee" <?php if ($_POST['food'] == 'Tea and Coffee') { echo 'selected="selected"'; } ?>>Tea and Coffee</option> <option value = "Make Your Own" <?php if ($_POST['food'] == 'Make Your Own') { echo 'selected="selected"'; } ?>>Make Your Own</option> </select> <!-- <select name = "food"> <option value = "Cafe">Cafe</option> <option value="None">None</option> <option value ="Tea and Coffee">Tea and Coffee</option> <option value = "Make Your Own">Make Your Own</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Radio Frequency</td> <td><input type='text' name='radio_frequency' size = '40'maxlength='50' value = '<?php echo $radio_frequency; ?>' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' value = '<?php echo $radio_callsign; ?>' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td> <select name = "radio_type"> <option value = "Safety Com" <?php if ($_POST['radio_type'] == 'Safety Com') { echo 'selected="selected"'; } ?>>Safety Com</option> <option value = "Air Ground" <?php if ($_POST['radio_type'] == 'Air Ground') { echo 'selected="selected"'; } ?>>Air Ground</option> <option value = "Approach" <?php if ($_POST['radio_type'] == 'Approach') { echo 'selected="selected"'; } ?>>Approach</option> <option value = "Tower" <?php if ($_POST['radio_type'] == 'Tower') { echo 'selected="selected"'; } ?>>Tower</option> </select> <!-- <select name = "radio_type"> <option value = "Sefety Com">Safety Com</option> <option value="Air Ground">Air Ground</option> <option value ="Approach">Approach</option> <option value = "Tower">Tower</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Other Radio</td> <td><input type='text' name='other_radio' size = '40' maxlength='50' value = '<?php echo $other_radio; ?>' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td> <select name = "fuel"> <option value = "AvGas" <?php if ($_POST['fuel'] == 'AvGas') { echo 'selected="selected"'; } ?>>AvGas</option> <option value = "MoGas" <?php if ($_POST['fuel'] == 'MoGas') { echo 'selected="selected"'; } ?>>MoGas</option> <option value = "AvGas and MoGas" <?php if ($_POST['fuel'] == 'AvGas and MoGas') { echo 'selected="selected"'; } ?>>AvGas and MoGas</option> <option value = "We will sort you some" <?php if ($_POST['fuel'] == 'We will sort you some') { echo 'selected="selected"'; } ?>>We will sort you some</option> <option value = "None" <?php if ($_POST['fuel'] == 'None') { echo 'selected="selected"'; } ?>>None</option> </select> <!-- <select name = "fuel"> <option value = "AvGas">AvGas</option> <option value="MoGas">MoGas</option> <option value ="AvGas and MoGas">AvGas and MoGas</option> <option value = "We will sort you some">We will sort you some</option> <option value = "None">None</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Landing Fee</td> <td><input type='text' name='landing_fee' size = '40' maxlength='50' value = '<?php echo $landing_fee; ?>' /></td> <td>£ or Nill </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td> <select name = "operating_hours"> <option value = "SR - SS" <?php if ($_POST['operating_hours'] == 'SR - SS') { echo 'selected="selected"'; } ?>>SR - SS</option> <option value="Other - See Remarks" <?php if ($_POST['operating_hours'] == 'Other - See Remarks') { echo 'selected="selected"'; } ?>>Other - See Remarks</option> </select> <!-- <select name = "operating_hours"> <option value = "SR - SS">Sunrise - Sunset</option> <option value="See Remarks">Other - See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Maintenance?</td> <td> <select name = "maintenance"> <option value = "Yes" <?php if ($_POST['maintenance'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['maintenance'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "maintenance"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Hangarage?</td> <td> <select name = "hangarage"> <option value = "Yes" <?php if ($_POST['hangarage'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['hangarage'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "hangarage"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Parking?</td> <td> <select name = "parking"> <option value = "Yes" <?php if ($_POST['parking'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['parking'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "parking"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Accommodation?</td> <td> <select name = "accommodation"> <option value = "Yes" <?php if ($_POST['accommodation'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['accommodation'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "accommodation"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>School?</td> <td> <select name = "school"> <option value = "Flexwing" <?php if ($_POST['school'] == 'Flexwing') { echo 'selected="selected"'; } ?>>Flexwing</option> <option value="3 Axis" <?php if ($_POST['school'] == '3 Axis') { echo 'selected="selected"'; } ?>>3 Axis</option> <option value = "All Microlight" <?php if ($_POST['school'] == 'All Microlight') { echo 'selected="selected"'; } ?>>All Microlight</option> <option value="GA" <?php if ($_POST['school'] == 'GA') { echo 'selected="selected"'; } ?>>GA</option> <option value="Gyro" <?php if ($_POST['school'] == 'Gyro') { echo 'selected="selected"'; } ?>>Gyro</option> <option value="Microlight and Gyro" <?php if ($_POST['school'] == 'Microlight and Gyro') { echo 'selected="selected"'; } ?>>Microlight and Gyro</option> <option value="Other See Comments" <?php if ($_POST['school'] == 'Other See Comments') { echo 'selected="selected"'; } ?>>Other See Comments</option> </select> <!--<select name = "school"> <option value = "Flexwing">Flexwing </option> <option value="3 Axis">3 Axis</option> <option value="All Microlight">All Mircolight</option> <option value="GA">GA</option> <option value="Gyro">Gyro</option> <option value="Other See Remarks">Other, See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Remarks:</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Warnings:</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Web Links</td> <td><textarea name= "weblinks" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $weblinks; ?></textarea></td> <td>Link to airfield website</td> </tr> <tr> <td> </td> <td>Operator Details</td> <td><textarea name= "operator" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $operator; ?></textarea></td> <td>As much info as possible</td> </tr> <tr> <td> </td> <td>Google Iframe Image</td> <td><textarea name= "google_image" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $google_image; ?></textarea></td> <td>700 x 700 pixels please. <a href="http://www.youtube.com/watch?v=gVRWhLEvt-I" target = "_blank">Watch Video here for How to Get the Image from Google</a></td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "Public Key Entered Here"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?>
  10. Thanks, I've done that. Please could you remove my post with the code in it. I've only just realised it's showing my captcha material
  11. Thanks mate but I'm new to all this. I couldn't figure out exactly where I would put that in my code. Please can someone take a look at the following and let me know where it should go. Sorry for being thick. Regards Vince Gledhill <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "VinnyG"; $password = 'thepassword'; $db_name = 'sitename'; $username = $_POST['username']; $height_above = $_POST['height_above']; $mb_diff = $_POST['mb_diff']; $alternative = $_POST['alternative']; $ppr = $_POST['ppr']; $general_location = $_POST['general_location']; $location_grid = $_POST['location_grid']; $runway_numbers = $_POST['runway_numbers']; $circuit_direction = $_POST['circuit_direction']; $circuit_height = $_POST['circuit_height']; $runway_length = $_POST['runway_length']; $surface = $_POST['surface']; $food = $_POST['food']; $radio_frequency = $_POST['radio_frequency']; $radio_callsign = $_POST['radio_callsign']; $radio_type = $_POST['radio_type']; $other_radio = $_POST['other_radio']; $fuel = $_POST['fuel']; $landing_fee = $_POST['landing_fee']; $operating_hours = $_POST['operating_hours']; $maintenance = $_POST['maintenance']; $hangarage = $_POST['hangarage']; $parking = $_POST['parking']; $accommodation = $_POST['accommodation']; $school = $_POST['school']; $remarks = $_POST['remarks']; $warnings = $_POST['warnings']; $weblinks = $_POST['weblinks']; $operator = $_POST['operator']; $google_image = $_POST['google_image']; $errorstring = ""; // default value of errorstring if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "PK Removed"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($username =="") $errorstring = $errorstring. "Airfield Name<br>"; if ($height_above =="") $errorstring = $errorstring. "Height Above Mean Sea Level<br>"; if ($mb_diff =="") $errorstring = $errorstring. "mb Difference<br>"; if ($alternative =="") $errorstring = $errorstring. "Alternative Airfield<br>"; if ($general_location =="") $errorstring = $errorstring. "General Location<br>"; if ($location_grid =="") $errorstring = $errorstring. "Grid Reference<br>"; if ($runway_numbers =="") $errorstring = $errorstring. "Runway Numbers<br>"; if ($circuit_direction =="") $errorstring = $errorstring. "Circuit Direction<br>"; if ($circuit_height =="") $errorstring = $errorstring. "Circuit Height<br>"; if ($runway_length =="") $errorstring = $errorstring. "Runway Length<br>"; if ($radio_frequency =="") $errorstring = $errorstring. "Radio Frequency<br>"; if ($radio_callsign =="") $errorstring = $errorstring. "Radio Callsign<br>"; if ($other_radio =="") $errorstring = $errorstring. "Other Radio<br>"; if ($landing_fee =="") $errorstring = $errorstring. "Landing Fee<br>"; if ($remarks =="") $errorstring = $errorstring. "Remarks<br>"; if ($warnings =="") $errorstring = $errorstring. "Warnings<br>"; if ($weblinks =="") $errorstring = $errorstring. "Web Links<br>"; if ($operator =="") $errorstring = $errorstring. "Operator<br>"; if ($google_image =="") $errorstring = $errorstring. "Google Image<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr, general_location, location_grid, runway_numbers, circuit_direction, circuit_height, runway_length, surface, food, radio_frequency, radio_callsign, radio_type, other_radio, fuel, landing_fee, operating_hours, maintenance, hangarage, parking, accommodation, school, remarks, warnings, weblinks, operator, google_image) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr', '$general_location', '$location_grid', '$runway_numbers', '$circuit_direction', '$circuit_height', '$runway_length', '$surface', '$food', '$radio_frequency', '$radio_callsign', '$radio_type', '$other_radio', '$fuel', '$landing_fee', '$operating_hours', '$maintenance', '$hangarage', '$parking', '$accommodation' , '$school', '$remarks', '$warnings', '$weblinks', '$operator', '$google_image')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your airfield has been submitted."; include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#c9e1d0"> <caption> Submit Your Airfield Details </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Airfield Name</td> <td><input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'></td> <td>Ince Blundell</td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above' size = '40' maxlength= '30'value = '<?php echo $height_above; ?>'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'value = '<?php echo $mb_diff; ?>'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td> <select name = "ppr"> <option value = "Yes" <?php if ($_POST['ppr'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['ppr'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>General Location</td> <td><input type='text' name='general_location' size = '40' maxlength='50' value = '<?php echo $general_location; ?>' /></td> <td>3 Nm North Luton</td> </tr> <tr> <td> </td> <td>Location Grid Reference</td> <td><textarea name= "location_grid" input type = 'text' rows = "2" cols = "29" /><?php echo $location_grid; ?></textarea></td> <td> 53°57'7.68"N<br /> 1°10'30.33"W</td> </tr> <tr> <td> </td> <td>Runway Numbers</td> <td><textarea name= "runway_numbers" input type = 'text' rows = "5" cols = "29" /><?php echo $runway_numbers; ?></textarea></td> <td><p>This format please<br /> 05-23<br /> 18-36<br /> 14-22 </p></td> </tr> <tr> <td> </td> <td>Circuit Direction</td> <td><textarea name= "circuit_direction" input type = "text" rows = "5" cols = "29" /><?php echo $circuit_direction; ?></textarea></td> <td><p>05-LH<br /> 23-RH<br /> 14-LH </p></td> </tr> <tr> <td> </td> <td>Circuit Height</td> <td><input type='text' name='circuit_height' size = '40' maxlength='50' value = '<?php echo $circuit_height; ?>' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' value = '<?php echo $runway_length; ?>' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td> <select name = "surface"> <option value = "Grass" <?php if ($_POST['surface'] == 'Grass') { echo 'selected="selected"'; } ?>>Grass</option> <option value = "Tarmac" <?php if ($_POST['surface'] == 'Tarmac') { echo 'selected="selected"'; } ?>>Tarmac</option> <option value = "Concrete" <?php if ($_POST['surface'] == 'Concrete') { echo 'selected="selected"'; } ?>>Concrete</option> <option value = "Dirt" <?php if ($_POST['surface'] == 'Dirt') { echo 'selected="selected"'; } ?>>Dirt</option> </select> <!-- <select name = "surface"> <option value = "Grass">Grass</option> <option value="Tarmac">Tarmac</option> <option value ="Concrete">Concrete</option> <option value = "Dirt">Dirt</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Food?</td> <td> <select name = "food"> <option value = "Cafe" <?php if ($_POST['food'] == 'Cafe') { echo 'selected="selected"'; } ?>>Cafe</option> <option value = "None" <?php if ($_POST['food'] == 'None') { echo 'selected="selected"'; } ?>>None</option> <option value = "Tea and Coffee" <?php if ($_POST['food'] == 'Tea and Coffee') { echo 'selected="selected"'; } ?>>Tea and Coffee</option> <option value = "Make Your Own" <?php if ($_POST['food'] == 'Make Your Own') { echo 'selected="selected"'; } ?>>Make Your Own</option> </select> <!-- <select name = "food"> <option value = "Cafe">Cafe</option> <option value="None">None</option> <option value ="Tea and Coffee">Tea and Coffee</option> <option value = "Make Your Own">Make Your Own</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Radio Frequency</td> <td><input type='text' name='radio_frequency' size = '40'maxlength='50' value = '<?php echo $radio_frequency; ?>' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' value = '<?php echo $radio_callsign; ?>' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td> <select name = "radio_type"> <option value = "Safety Com" <?php if ($_POST['radio_type'] == 'Safety Com') { echo 'selected="selected"'; } ?>>Safety Com</option> <option value = "Air Ground" <?php if ($_POST['radio_type'] == 'Air Ground') { echo 'selected="selected"'; } ?>>Air Ground</option> <option value = "Approach" <?php if ($_POST['radio_type'] == 'Approach') { echo 'selected="selected"'; } ?>>Approach</option> <option value = "Tower" <?php if ($_POST['radio_type'] == 'Tower') { echo 'selected="selected"'; } ?>>Tower</option> </select> <!-- <select name = "radio_type"> <option value = "Sefety Com">Safety Com</option> <option value="Air Ground">Air Ground</option> <option value ="Approach">Approach</option> <option value = "Tower">Tower</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Other Radio</td> <td><input type='text' name='other_radio' size = '40' maxlength='50' value = '<?php echo $other_radio; ?>' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td> <select name = "fuel"> <option value = "AvGas" <?php if ($_POST['fuel'] == 'AvGas') { echo 'selected="selected"'; } ?>>AvGas</option> <option value = "MoGas" <?php if ($_POST['fuel'] == 'MoGas') { echo 'selected="selected"'; } ?>>MoGas</option> <option value = "AvGas and MoGas" <?php if ($_POST['fuel'] == 'AvGas and MoGas') { echo 'selected="selected"'; } ?>>AvGas and MoGas</option> <option value = "We will sort you some" <?php if ($_POST['fuel'] == 'We will sort you some') { echo 'selected="selected"'; } ?>>We will sort you some</option> <option value = "None" <?php if ($_POST['fuel'] == 'None') { echo 'selected="selected"'; } ?>>None</option> </select> <!-- <select name = "fuel"> <option value = "AvGas">AvGas</option> <option value="MoGas">MoGas</option> <option value ="AvGas and MoGas">AvGas and MoGas</option> <option value = "We will sort you some">We will sort you some</option> <option value = "None">None</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Landing Fee</td> <td><input type='text' name='landing_fee' size = '40' maxlength='50' value = '<?php echo $landing_fee; ?>' /></td> <td>£ or Nill </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td> <select name = "operating_hours"> <option value = "SR - SS" <?php if ($_POST['operating_hours'] == 'SR - SS') { echo 'selected="selected"'; } ?>>SR - SS</option> <option value="Other - See Remarks" <?php if ($_POST['operating_hours'] == 'Other - See Remarks') { echo 'selected="selected"'; } ?>>Other - See Remarks</option> </select> <!-- <select name = "operating_hours"> <option value = "SR - SS">Sunrise - Sunset</option> <option value="See Remarks">Other - See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Maintenance?</td> <td> <select name = "maintenance"> <option value = "Yes" <?php if ($_POST['maintenance'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['maintenance'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "maintenance"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Hangarage?</td> <td> <select name = "hangarage"> <option value = "Yes" <?php if ($_POST['hangarage'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['hangarage'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "hangarage"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Parking?</td> <td> <select name = "parking"> <option value = "Yes" <?php if ($_POST['parking'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['parking'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "parking"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Accommodation?</td> <td> <select name = "accommodation"> <option value = "Yes" <?php if ($_POST['accommodation'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value="No" <?php if ($_POST['accommodation'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> <!-- <select name = "accommodation"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>School?</td> <td> <select name = "school"> <option value = "Flexwing" <?php if ($_POST['school'] == 'Flexwing') { echo 'selected="selected"'; } ?>>Flexwing</option> <option value="3 Axis" <?php if ($_POST['school'] == '3 Axis') { echo 'selected="selected"'; } ?>>3 Axis</option> <option value = "All Microlight" <?php if ($_POST['school'] == 'All Microlight') { echo 'selected="selected"'; } ?>>All Microlight</option> <option value="GA" <?php if ($_POST['school'] == 'GA') { echo 'selected="selected"'; } ?>>GA</option> <option value="Gyro" <?php if ($_POST['school'] == 'Gyro') { echo 'selected="selected"'; } ?>>Gyro</option> <option value="Microlight and Gyro" <?php if ($_POST['school'] == 'Microlight and Gyro') { echo 'selected="selected"'; } ?>>Microlight and Gyro</option> <option value="Other See Comments" <?php if ($_POST['school'] == 'Other See Comments') { echo 'selected="selected"'; } ?>>Other See Comments</option> </select> <!--<select name = "school"> <option value = "Flexwing">Flexwing </option> <option value="3 Axis">3 Axis</option> <option value="All Microlight">All Mircolight</option> <option value="GA">GA</option> <option value="Gyro">Gyro</option> <option value="Other See Remarks">Other, See Remarks</option> </select> --> </td> <td> </td> </tr> <tr> <td> </td> <td>Remarks:</td> <td><textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Warnings:</td> <td><textarea name= "warnings" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $warnings; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Web Links</td> <td><textarea name= "weblinks" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $weblinks; ?></textarea></td> <td>Link to airfield website</td> </tr> <tr> <td> </td> <td>Operator Details</td> <td><textarea name= "operator" input="input" type = 'text' rows = "3" cols = "29" /><?php echo $operator; ?></textarea></td> <td>As much info as possible</td> </tr> <tr> <td> </td> <td>Google Iframe Image</td> <td><textarea name= "google_image" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $google_image; ?></textarea></td> <td>700 x 700 pixels please. <a href="http://www.youtube.com/watch?v=gVRWhLEvt-I" target = "_blank">Watch Video here for How to Get the Image from Google</a></td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "Removed"; // you got this from the signup page echo recaptcha_get_html($publickey);?></td> </tr> </table> </form> </body> </html> <?php } ?> MOD EDIT: Captcha keys removed.
  12. Brilliant Zer0day. You are my hero. Where do you live in the world? Fancy a go in a microlight aircraft? I'll get you a go.
  13. My data input form is not working with the first few people who have tried to use it. I think it is because they are putting ' or " or some other character that is not allowed into the database. Any ideas how I can fix it?
  14. Hi Zer0Day, thanks for that. Essentially the different buttons do the same thing. When you go flying you can be one of either but not two of. In other words the button should do the same for each discipline. It just takes the time that the pilot / student has done and puts it into the correct box. So, just like you have done for "captain Weightshift" The pilot / student goes for a flight. The flight time is from take off to landing. They put this time in the boxes Take Off Hrs and Take off Mins, then Landing Hrs and Landing Mins. The time of the flight should then be inserted in any of the 5 boxes dependent upon whether the Pilot is a "captain of a weightshift aircraft" "Student in a weightshift aircraft" Captain in a 3 axis aircraft Student in a 3 axis aircraft Or is a passenger and the flight is for interest only.
  15. Thanks and well spotted Pikachu2000 but I've still got the same blank screen.
  16. Here's my updated code but I've messed it all up and all I get is a blank screen now :-( <?php if(isset($_POST['reset'])) { header('Location: index1.php'); } ?> <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "vinny"; $password = 'thepassword'; $db_name = 'logbook'; $today = date("Y-m-d"); $date = $_POST['date']; $type = $_POST['type']; $reg_01 = $_POST['reg_01']; $reg_02 = $_POST['reg_02']; $captain = $_POST['captain']; $passenger = $_POST['passenger']; $where_01 = $_POST['where_01']; $where_02 = $_POST['where_02']; $takeoff_hr = $_POST['takeoff_hr']; $takeoff_min = $_POST['takeoff_min']; $landing_hr = $_POST['landing_hr']; $landing_min = $_POST['landing_min']; $ws_captain_hrs = $_POST['ws_captain_hrs']; $ws_captain_min = $_POST['ws_captain_min']; $ws_student_hrs = $_POST['ws_student_hrs']; $ws_student_min = $_POST['ws_student_min']; $three_captain_hrs = $_POST['three_captain_hrs']; $three_captain_min = $_POST['three_captain_min']; $three_student_hrs = $_POST['three_student_hrs']; $three_student_min = $_POST['three_student_min']; $passenger_hrs = $_POST['passenger_hrs']; $passenger_min = $_POST['passenger_min']; $remarks = $_POST['remarks']; if(isset($_POST['autofill_ws_captain']) && isset($_POST['takeoff_hr']) && isset($_POST['takeoff_min']) && isset($_POST['landing_hr']) && isset($_POST['landing_min'])) { $ws_captain_hrs = $takeoff_hr - $landing_hr; $ws_captain_hrs = str_replace("-", "", $ws_captain_hrs); if(strlen($ws_captain_hrs) == "1") { $ws_captain_hrs = "0".$ws_captain_hrs; } $ws_captain_min = $takeoff_min - $landing_min; $ws_captain_min = str_replace("-", "", $ws_captain_min); if(strlen($ws_captain_min) == "1") { $ws_captain_min = "0".$ws_captain_min; } } if(isset($_POST['autofill_ws_student'])) && isset($_POST['takeoff_hr']) && isset($_POST['takeoff_min']) && isset($_POST['landing_hr']) && isset($_POST['landing_min'])) { $ws_student_hrs = $takeoff_hr - $landing_hr; $ws_student_hrs = str_replace("-", "", $ws_student_hrs); if(strlen($ws_student_hrs) == "1") { $ws_student_hrs = "0".$ws_student_hrs; } $ws_student_min = $takeoff_min - $landing_min; $ws_student_min = str_replace("-", "", $ws_student_min); if(strlen($ws_student_min) == "1") { $ws_student_min = "0".$ws_student_min; } elseif(isset($_POST['autofill_3_captain'])) { // Calculate 3_captain fields } elseif(isset($_POST['autofill_3_student'])) { // Calculate 3_student fields } elseif(isset($_POST['today'])) { $date = date("Y-m-d"); } $errorstring = ""; // default value of errorstring if(isset($_POST['save_flight'])) { // Validate all the code inputs that are required fields if ($date =="") $errorstring = $errorstring. "Date<br>"; if ($type =="") $errorstring = $errorstring. "Aircraft Type<br>"; if ($reg_01 =="") $errorstring = $errorstring. "Reg Prefix<br>"; if ($reg_02 =="") $errorstring = $errorstring. "Registration Mark<br>"; if ($captain =="") $errorstring = $errorstring. "Captain<br>"; if ($where_01 =="") $errorstring = $errorstring. "Flight From<br>"; if ($where_02 =="") $errorstring = $errorstring. "Flight To<br>"; if ($takeoff_hr =="") $errorstring = $errorstring. "Takeoff Hours<br>"; if ($takeoff_min =="") $errorstring = $errorstring. "Takeoff Minutes<br>"; if ($landing_hr =="") $errorstring = $errorstring. "Landing Hours<br>"; if ($landing_min =="") $errorstring = $errorstring. "Landing Minutes<br>"; // does the errorstring = "nothing"? if ($errorstring !="") echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); elseif(isset($_POST['save_flight'])) { //echo "Your data has been saved"; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $insert_query = "INSERT INTO pilots_logbook (date, type, reg_01, reg_02, captain, passenger, where_01, where_02, takeoff_hr, takeoff_min, landing_hr, landing_min, ws_captain_hrs, ws_captain_min, ws_student_hrs, ws_student_min, three_captain_hrs, three_captain_min, three_student_hrs, three_student_min, passenger_hrs, passenger_min, remarks) VALUES ('$date', '$type', '$reg_01', '$reg_02', '$captain', '$passenger', '$where_01', '$where_02', '$takeoff_hr', '$takeoff_min', '$landing_hr', '$landing_min', '$ws_captain_hrs', '$ws_captain_min', '$ws_student_hrs', '$ws_student_min', '$three_captain_hrs', '$three_captain_min', '$three_student_hrs', '$three_student_min','$passenger_hrs', '$passenger_min', '$remarks')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your logbook entry has been saved."; } } ?> <p>Use this form to add an entry to your logbook.</p> <form name="form1" method="post" action="index1.php"> <table width="650" border="1" cellspacing="0" cellpadding="5"> <tr> <td>Required *</td> <td> </td> <td>This Format Only</td> </tr> <tr> <td width="180">Date *</td> <td width="300"> <input type="text" name="date" id="date" size="40"/ value="<?php echo $today; ?>" /></td> <td width="170">YYYY-MM-DD</td> </tr> <tr> <td>Aircraft Type *</td> <td><input type="text" name="type" id="type" size="40" / value="<?php echo $type; ?>" /></td> <td>E.G. Quantum</td> </tr> <tr> <td>Reg Number *</td> <td><input type="text" name="reg_01" id="reg_01" size="5" value="<?php echo $reg_01; ?>" /> - <input type="text" name="reg_02" id="reg_02" size="15" value="<?php echo $reg_02; ?>" /></td> <td>G - ABCD</td> </tr> <tr> <td>Captain *</td> <td><input type="text" name="captain" id="captain" size="40" value="<?php echo $captain; ?>" /></td> <td>Name of Captain</td> </tr> <tr> <td>Passenger or Student</td> <td><input type="text" name="passenger" id="passenger" size="40" value="<?php echo $passenger; ?>" /></td> <td>Were you? P or S</td> </tr> <tr> <td>Flight From *</td> <td><input type="text" name="where_01" id="where_01" size="40" value="<?php echo $where_01; ?>" /></td> <td>Take off Airfield</td> </tr> <tr> <td>Flight To *</td> <td><input type="text" name="where_02" id="where_02" size="40" value="<?php echo $where_02; ?>" /></td> <td>Landing Airfield</td> </tr> <tr> <td>Takeoff GMT *</td> <td> <label> Hr <input type="text" name="takeoff_hr" id="takeoff_hr" size="10" value="<?php echo $takeoff_hr; ?>" /> Min <input type="text" name="takeoff_min" id="takeoff_min" size="10" value="<?php echo $takeoff_min; ?>" /> </label> </td> <td>24 Hr Format Only</td> </tr> <tr> <td>Landing GMT *</td> <td> <label> Hr <input type="text" name="landing_hr" id="landing_hr" size="10" value="<?php echo $landing_hr; ?>" /> Min <input type="text" name="landing_min" id="landing_min" size="10" value="<?php echo $landing_min; ?>" /> </label> </td> <td>24 Hr Format Only</td> </tr> <tr> <td>Captain Weighshift</td> <td> <label>Hrs <input type="text" name="ws_captain_hrs" id="ws_captain_hrs" size="10" value="<?php echo $ws_captain_hrs; ?>" /></label> <label> Min <input type="text" name="ws_captain_min" id="ws_captain_min" size="10" value="<?php echo $ws_captain_min; ?>" /> <input type="submit" name="autofill_ws_captain" id="autofill_ws_captain" value="Auto Insert" /> </label> </td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student Weightshift</td> <td> <label>Hrs <input type="text" name="ws_student_hrs" id="ws_student_hrs" size="10" value="<?php echo $ws_student_hrs; ?>" /></label> <label> Min <input type="text" name="ws_student_min" id="ws_student_min" size="10" value="<?php echo $ws_student_min; ?>" /> <input type="submit" name="autofill_ws_student" id="autofill_ws_student" value="Auto Insert" /> </label> </td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Captain 3 Axis</td> <td> <label>Hrs <input type="text" name="three_captain_hrs" id="three_captain_hrs" size="10" value="<?php echo $three_captain_hrs; ?>" /></label> <label> Min <input type="text" name="three_captain_min" id="three_captain_min" size="10" value="<?php echo $three_captain_min; ?>" /> <input type="submit" name="autofill_3_captain" id="autofill_3_captain" value="Auto Insert" /> </label> </td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student 3 Axis</td> <td> <label>Hrs <input type="text" name="three_student_hrs" id="three_student_hrs" size="10" value="<?php echo $three_student_hrs; ?>" /></label> <label> Min <input type="text" name="three_student_min" id="three_student_min" size="10" value="<?php echo $three_student_min; ?>" /> <input type="submit" name="autofill_3_student" id="autofill_3_student" value="Auto Insert" /> </label> </td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Passenger Interest Only</td> <td> Hrs <input type="text" name="passenger_hrs" id="passenger_hrs" size="10" value="<?php echo $passenger_hrs; ?>" /> Min <input type="text" name="passenger_min" id="passenger_min" size="10" value="<?php echo $passenger_min; ?>" /> <input type="submit" name="passenger_button" id="passenger_button" value="Auto Insert" /> </td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Remarks</td> <td><textarea name="remarks" id="remarks" cols="45" rows="5"><?php echo $remarks; ?></textarea></td> <td>Went to get microlight forum cup from XYZ airfield. Maximum 500 characters</td> </tr> <tr> <td><input type="submit" name="save_flight" id="save_flight" value="Save Flight" /></td> <td><input type="submit" name="reset" id="reset" value="Reset Form" /></td> <td> </td> </tr> </table> <p> </p> <p> </p> </body> </html>
  17. Thanks mate, when I named it index.php that sorted it. Now I just need to get your code into the other 4 buttons
  18. Hi zer0day Thank you very much for your input. When I try to use it now I just get a 404 cannot find index.php on this server. Please could you tell me where I'm going wrong?
  19. Brilliant, thanks for that, I have declared the $today variable and have echo'd it into the box. That will be there by default, if the user wants a different "date" then they can enter it. Sorted.
  20. Hello people. Thank you to everyone who has helped me in the past, this is a great forum full of very helpful members. I am trying to put a pilots logbook application together for the members at microlightforum.com and here is the form that I have put together. What I would like to know is how to code the first "Auto Insert" button so that it takes the time from the variables $takeoff_hr and $takeoff_min and $landing_hr, $landing_min I would like the time difference from taking off to landing putting in the "ws_captain_hrs" box and the "ws_captain_min" box. Therefore if someone took off at 12.30 and landed at 13.50 the "ws_captain_hrs" box should read "1" and the "ws_captain_min" box should read "20" The idea behind this is that it makes it easier for the user to only have to insert take off time and landing time, then click the appropriate button to put the data into the box. <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "vinny"; $password = 'thepassword'; $db_name = 'logbook'; $date = $_POST['date']; $type = $_POST['type']; $reg_01 = $_POST['reg_01']; $reg_02 = $_POST['reg_02']; $captain = $_POST['captain']; $passenger = $_POST['passenger']; $where_01 = $_POST['where_01']; $where_02 = $_POST['where_02']; $takeoff_hr = $_POST['takeoff_hr']; $takeoff_min = $_POST['takeoff_min']; $landing_hr = $_POST['landing_hr']; $landing_min = $_POST['landing_min']; $ws_captain_hrs = $_POST['ws_captain_hrs']; $ws_captain_min = $_POST['ws_captain_min']; $ws_student_hrs = $_POST['ws_student_hrs']; $ws_student_min = $_POST['ws_student_min']; $three_captain_hrs = $_POST['three_captain_hrs']; $three_captain_min = $_POST['three_captain_min']; $three_student_hrs = $_POST['three_student_hrs']; $three_student_min = $_POST['three_student_min']; $passenger_hrs = $_POST['passenger_hrs']; $passenger_min = $_POST['passenger_min']; $remarks = $_POST['remarks']; $errorstring = ""; // default value of errorstring if(isset($_POST['save_flight'])) { // Validate all the code inputs that are required fields if ($date =="") $errorstring = $errorstring. "Date<br>"; if ($type =="") $errorstring = $errorstring. "Aircraft Type<br>"; if ($reg_01 =="") $errorstring = $errorstring. "Reg Prefix<br>"; if ($reg_02 =="") $errorstring = $errorstring. "Registration Mark<br>"; if ($captain =="") $errorstring = $errorstring. "Captain<br>"; if ($where_01 =="") $errorstring = $errorstring. "Flight From<br>"; if ($where_02 =="") $errorstring = $errorstring. "Flight To<br>"; if ($takeoff_hr =="") $errorstring = $errorstring. "Takeoff Hours<br>"; if ($takeoff_min =="") $errorstring = $errorstring. "Takeoff Minutes<br>"; if ($landing_hr =="") $errorstring = $errorstring. "Landing Hours<br>"; if ($landing_min =="") $errorstring = $errorstring. "Landing Minutes<br>"; // does the errorstring = "nothing"? if ($errorstring !="") echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $insert_query = "INSERT INTO pilots_logbook (date, type, reg_01, reg_02, captain, passenger, where_01, where_02, takeoff_hr, takeoff_min, landing_hr, landing_min, ws_captain_hrs, ws_captain_min, ws_student_hrs, ws_student_min, three_captain_hrs, three_captain_min, three_student_hrs, three_student_min, passenger_hrs, passenger_min, remarks) VALUES ('$date', '$type', '$reg_01', '$reg_02', '$captain', '$passenger', '$where_01', '$where_02', '$takeoff_hr', '$takeoff_min', '$landing_hr', '$landing_min', '$ws_captain_hrs', '$ws_captain_min', '$ws_student_hrs', '$ws_student_min', '$three_captain_hrs', '$three_captain_min', '$three_student_hrs', '$three_student_min','$passenger_hrs', '$passenger_min', '$remarks')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your logbook entry has been saved."; } } ?> <p>Use this form to add an entry to your logbook.</p> <form name = "form1" method ="post" action=""> <table width="650" border="1" cellspacing="0" cellpadding="5"> <tr> <td>Required *</td> <td> </td> <td>This Format Only</td> </tr> <tr> <td width="180">Date *</td> <td width="300"> <input type="text" name="date" id="date" size = "25"/> </label> <input type="submit" name="today" id="today" value="Add Today" /></td> <td width="170">YYYY-MM-DD</td> </tr> <tr> <td>Aircraft Type *</td> <td><input type="text" name="type" id="type" size = "40" /></td> <td>E.G. Quantum</td> </tr> <tr> <td>Reg Number *</td> <td><input type="text" name="reg_01" id="reg_01" size = "5" /> - <input type="text" name="reg_02" id="reg_02" size = "15"/></td> <td>G - ABCD</td> </tr> <tr> <td>Captain *</td> <td><input type="text" name="captain" id="captain" size = "40" /></td> <td>Name of Captain</td> </tr> <tr> <td>Passenger or Student</td> <td><input type="text" name="passenger" id="passenger" size = "40" /></td> <td>Were you? P or S</td> </tr> <tr> <td>Flight From *</td> <td><input type="text" name="where_01" id="where_01" size = "40" /></td> <td>Take off Airfield</td> </tr> <tr> <td>Flight To *</td> <td><input type="text" name="where_02" id="where_02" size = "40" /></td> <td>Landing Airfield</td> </tr> <tr> <td>Takeoff GMT *</td> <td><label>Hr <input type="text" name="takeoff_hr" id="takeoff_hr" size = "10" /> Min <input type="text" name="takeoff_min" id="takeoff_min" size="10"/> </label></td> <td>24 Hr Format Only</td> </tr> <tr> <td>Landing GMT *</td> <td><label>Hr <input type="text" name="landing_hr" id="landing_hr" size="10" /> Min <input type="text" name="landing_min" id="landing_min" size="10" /> </label></td> <td>24 Hr Format Only</td> </tr> <tr> <td>Captain Weighshift</td> <td><label>Hrs <input type="text" name="ws_captain_hrs" id="ws_captain_hrs" size = "10"/></label> <label>Min <input type="text" name="ws_captain_min" id="ws_captain_min" size = "10" /> <input type="submit" name="autofill_ws_captain" id="autofill_ws_captain" value="Auto Insert" /> <!--This is the button I would like to take the time from the take off and put it into the captain weightshift hrs and min boxes --> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student Weightshift</td> <td><label>Hrs <input type="text" name="ws_student_hrs" id="ws_student_hrs" size = "10"/></label> <label>Min <input type="text" name="ws_student_min" id="ws_student_min" size="10" /> <input type="submit" name="autofill_ws_student" id="autofill_ws_student" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Captain 3 Axis</td> <td><label>Hrs <input type="text" name="three_captain_hrs" id="three_captain_hrs" size = "10"/> </label> <label>Min <input type="text" name="three_captain_min" id="three_captain_min" size = "10" /> <input type="submit" name="autofill_3_captain" id="autofill_3_captain" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student 3 Axis</td> <td><label>Hrs <input type="text" name="three_student_hrs" id="three_student_hrs" size = "10"/> </label> <label>Min <input type="text" name="three_student_min" id="three_student_min" size = "10" /> <input type="submit" name="autofill_3_student" id="autofill_3_student" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Passenger Interest Only</td> <td>Hrs <input type="text" name="passenger_hrs" id="passenger_hrs" size="10"/> Min <input type="text" name="passenger_min" id="passenger_min" size="10"/> <input type="submit" name="passenger_button" id="passenger_button" value="Auto Insert" /></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Remarks</td> <td><textarea name="remarks" id="remarks" cols="45" rows="5"></textarea></td> <td>Went to get microlight forum cup from XYZ airfield. Maximum 500 characters</td> </tr> <tr> <td><input type="submit" name="save_flight" id="save_flight" value="Save Flight" /></td> <td><input type="submit" name="reset" id="reset" value="Reset Form" /></td> <td> </td> </tr> </table> <p> </p> <p> </p> </body> </html>
  21. Thanks mate. That's sorted it. Didn't realise that. Every day is a school day
  22. Hi People. I am having a problem with this form and for the life of me can't see where I have made the mistake. On line 33 I have commented where I get the problem. If I remove this line (or comment it out) and remove the insert statements for that line then it all works and I can see the php form on my live site. However, with this in, as it is, I can't see anything, I get a blank page altogether. Please, can anyone see my mistake? I have been going over the code now for ages and it's getting late, and I probably am missing something stupid. <!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>Untitled Document</title> </head> <body> <?php $host = 'localhost'; $usr = "vinny"; $password = 'thepassword'; $db_name = 'logbook'; $date = $_POST['date']; $type = $_POST['type']; $reg_01 = $_POST['reg_01']; $reg_02 = $_POST['reg_02']; $captain = $_POST['captain']; $passenger = $_POST['passenger']; $where_01 = $_POST['where_01']; $where_02 = $_POST['where_02']; $takeoff_hr = $_POST['takeoff_hr']; $takeoff_min = $_POST['takeoff_min']; $landing_hr = $_POST['landing_hr']; $landing_min = $_POST['landing_min']; $ws_captain_hrs = $_POST['ws_captain_hrs']; $ws_captain_min = $_POST['ws_captain_min']; $ws_student_hrs = $_POST['ws_student_hrs']; $ws_student_min = $_POST['ws_student_min']; $3_captain_hrs = $_POST['3_captain_hrs'];// I have a problem with this line or where it inserts this into the DB??? /*$3_captain_min = $_POST['3_captain_min']; $3_student_hrs = $_POST['3_student_hrs']; $3_student_min = $_POST['3_student_min']; */ $errorstring = ""; // default value of errorstring if(isset($_POST['save_flight'])) { // Validate all the code inputs that are required fields if ($date =="") $errorstring = $errorstring. "Date<br>"; if ($type =="") $errorstring = $errorstring. "Aircraft Type<br>"; if ($reg_01 =="") $errorstring = $errorstring. "Reg Prefix<br>"; if ($reg_02 =="") $errorstring = $errorstring. "Registration Mark<br>"; if ($captain =="") $errorstring = $errorstring. "Captain<br>"; if ($where_01 =="") $errorstring = $errorstring. "Flight From<br>"; if ($where_02 =="") $errorstring = $errorstring. "Flight To<br>"; if ($takeoff_hr =="") $errorstring = $errorstring. "Takeoff Hours<br>"; if ($takeoff_min =="") $errorstring = $errorstring. "Takeoff Minutes<br>"; if ($landing_hr =="") $errorstring = $errorstring. "Landing Hours<br>"; if ($landing_min =="") $errorstring = $errorstring. "Landing Minutes<br>"; // does the errorstring = "nothing"? if ($errorstring !="") echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $insert_query = "INSERT INTO pilots_logbook (date, type, reg_01, reg_02, captain, passenger, where_01, where_02, takeoff_hr, takeoff_min, landing_hr, landing_min, ws_captain_hrs, ws_captain_min, ws_student_hrs, ws_student_min, 3_captain_hrs) VALUES ('$date', '$type', '$reg_01', '$reg_02', '$captain', '$passenger', '$where_01', '$where_02', '$takeoff_hr', '$takeoff_min', '$landing_hr', '$landing_min', '$ws_captain_hrs', '$ws_captain_min', '$ws_student_hrs', '$ws_student_min', '$3_captain_hrs')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your logbook entry has been saved."; } } ?> <p>Use this form to add an entry to your logbook.</p> <form name = "form1" method ="post" action=""> <table width="650" border="1" cellspacing="0" cellpadding="5"> <tr> <td>Required *</td> <td> </td> <td>This Format Only</td> </tr> <tr> <td width="180">Date *</td> <td width="300"> <input type="text" name="date" id="date" size = "25"/> </label> <input type="submit" name="today" id="today" value="Add Today" /></td> <td width="170">YYYY-MM-DD</td> </tr> <tr> <td>Aircraft Type *</td> <td><input type="text" name="type" id="type" size = "40" /></td> <td>E.G. Quantum</td> </tr> <tr> <td>Reg Number *</td> <td><input type="text" name="reg_01" id="reg_01" size = "5" /> - <input type="text" name="reg_02" id="reg_02" size = "15"/></td> <td>G - ABCD</td> </tr> <tr> <td>Captain *</td> <td><input type="text" name="captain" id="captain" size = "40" /></td> <td>Name of Captain</td> </tr> <tr> <td>Passenger or Student</td> <td><input type="text" name="passenger" id="passenger" size = "40" /></td> <td>Were you? P or S</td> </tr> <tr> <td>Flight From *</td> <td><input type="text" name="where_01" id="where_01" size = "40" /></td> <td>Take off Airfield</td> </tr> <tr> <td>Flight To *</td> <td><input type="text" name="where_02" id="where_02" size = "40" /></td> <td>Landing Airfield</td> </tr> <tr> <td>Takeoff GMT *</td> <td><label>Hr <input type="text" name="takeoff_hr" id="takeoff_hr" size = "10" /> Min <input type="text" name="takeoff_min" id="takeoff_min" size="10"/> </label></td> <td>24 Hr Format Only</td> </tr> <tr> <td>Landing GMT *</td> <td><label>Hr <input type="text" name="landing_hr" id="landing_hr" size="10" /> Min <input type="text" name="landing_min" id="landing_min" size="10" /> </label></td> <td>24 Hr Format Only</td> </tr> <tr> <td>Captain Weighshift</td> <td><label>Hrs <input type="text" name="ws_captain_hrs" id="ws_captain_hrs" size = "10"/></label> <label>Min <input type="text" name="ws_captain_min" id="ws_captain_min" size = "10" /> <input type="submit" name="autofill_ws_captain" id="autofill_ws_captain" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student Weightshift</td> <td><label>Hrs <input type="text" name="ws_student_hrs" id="ws_student_hrs" size = "10"/></label> <label>Min <input type="text" name="ws_student_min" id="ws_student_min" size="10" /> <input type="submit" name="autofill_ws_student" id="autofill_ws_student" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Captain 3 Axis</td> <td><label>Hrs <input type="text" name="3_captain_hrs" id="3_captain_hrs" size = "10"/> </label> <label>Min <input type="text" name="3_captain_min" id="3_captain_min" size = "10" /> <input type="submit" name="autofill_3_captain" id="autofill_3_captain" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Student 3 Axis</td> <td><label>Hrs <input type="text" name="3_student_hrs" id="3_student_hrs" size = "10"/> </label> <label>Min <input type="text" name="3_student_min" id="3_student_min" size = "10" /> <input type="submit" name="autofill_3_student" id="autofill_3_student" value="Auto Insert" /> </label></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Passenger Interest Only</td> <td>Hrs <input type="text" name="passenger_only_hrs" id="passenger_only_hrs" size="10"/> Min <input type="text" name="passenger_only_mins" id="passenger_only_mins" size="10"/> <input type="submit" name="passenger_button" id="passenger_button" value="Auto Insert" /></td> <td>Button works it out and inserts it here</td> </tr> <tr> <td>Remarks</td> <td><textarea name="remarks" id="remarks" cols="45" rows="5"></textarea></td> <td>Went to get microlight forum cup from XYZ airfield. Maximum 500 characters</td> </tr> <tr> <td><input type="submit" name="save_flight" id="save_flight" value="Save Flight" /></td> <td><input type="submit" name="reset" id="reset" value="Reset Form" /></td> <td> </td> </tr> </table> <p> </p> <p> </p> </body> </html>
  23. Hi People. I am building a logbook application and have a form field where the user will enter a date. However, I would like to simplify it for the user and give them a button which would add "todays" date into the box for them. Please could someone tell me the code to do so. The date format in my DB is YYYY-MM-DD. The form would also need to take input from the user if they were adding info from a different day instead of today. Thanks in advance. <input type="text" name="date" id="date" size = "25"/> </label> <input type="submit" name="today" id="today" value="Add Today" />
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.