![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
VinceGledhill
Members-
Posts
133 -
Joined
-
Last visited
Everything posted by VinceGledhill
-
Hi People. Thank you for everyone who has helped me with my project so far. For security purposes I would like to add the reCapture from google to my form. Please see below my working (except the password obviously) code. I would like to insert the code from this reCaptcha page http://code.google.com/apis/recaptcha/docs/php.html but I'm not sure exactly where it should go and how it should be configured. Please could someone give me some advice. <!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 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"? 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 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> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Airfield' /></td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> <?php } ?> Code from the reCaptcha pages <html> <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers --> <!-- your HTML content --> <form method="post" action="verify.php"> <?php require_once('recaptchalib.php'); $publickey = "your_public_key"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <input type="submit" /> </form> <!-- more of your HTML content --> </body> </html> You would probably be better taking a look at the link above for the full instructions.
-
Thanks mate, I'll have a look at the capcha. The iframe gives us the best way of showing the live google map of the airfield in question. Anyone visiting the airfield can interact with the map which is it's biggest highlight.
-
Hi People. Thank you to everyone who has helped me so far with my project. I have an input form which is adding stuff to a database. Please could you help me "anti-spam" this code. Any advice would be gratefully received. BTW the last input box is google iframe google earth picture, we therefore will need to keep all of the characters that would be in a google iframe image. <!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 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"? 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 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='Have-It' /></td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> <?php } ?> Iframe code from google maps looks like this <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.google.co.uk/maps?ie=UTF8&ll=53.755207,-1.988525&spn=5.256048,11.228027&t=h&z=7&output=embed"></iframe><br /><small><a href="http://www.google.co.uk/maps?ie=UTF8&ll=53.755207,-1.988525&spn=5.256048,11.228027&t=h&z=7&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>
-
Validated Input in drop down fields
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Thanks Pikachu2000 all working now. You can see the results at http://www.microlight.co/index.php/additional Regards VinceG -
Validated Input in drop down fields
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
I have tried the GuiltyGear and on the Yes / No option as indicated here... <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> It works. However, when I modified it for a drop down with 4 options then it only shows the last option when I've actually clicked a different option? Any ideas? <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> -
Validated Input in drop down fields
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Hi Pikachu2000 thank you for your reply. I have inserted your code and it worked a treat, thanks. I have tried to modify it for another field I have which has 4 options. See code below my altered field. The problem I have is that when I test it out, even though I have got "tarmac" selected, when I go back after submitting a form with another empty field (therefore running the error code) I get "dirt" which is the last one showing as selected. <?php $surface_fields = array( 'Grass', 'Tarmac', 'Concrete', 'Dirt' ); ?> <select name = "surface"> <?php foreach( $surface_fields as $v ) { if( isset($_POST['surface']) && $v == $_POST['surface'] ) { $sel = 'selected="selected"'; } echo "<option value=\"{$v}\" {$sel}>{$v}</option>"; } ?> -
How do I show user completed form?
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Thanks for your input wildteen88. I have done as you said (see code below) but it is not showing the card. All I get is the Thank you message and nothing else? I have uploaded "resultcard.php" and it is in the same "folder" as the form_newest.php file. Any ideas? <!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 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"? 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 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); 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">Yes </option> <option value="No">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">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">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 = "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">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> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> <?php } ?> Here is the resultcard.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> <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>{$height_above from DB}</td> <td bgcolor = #E6F8EB>{$mb_diff from DB}</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #f7e5c6>Runway Numbers</td> <td bgcolor = #f7e5c6>Circuit Direction</td> <td bgcolor = #f7e5c6>Circuit Height</td> <td bgcolor = #f7e5c6>Runway Length</td> <td bgcolor = #f7e5c6>Runway Surface</td> <td bgcolor = #f7e5c6>Food? </td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </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> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB><p> </p></td> </tr> <tr> <td bgcolor = #f7e5c6>Opperating Hrs</td> <td bgcolor = #f7e5c6>Maintenance</td> <td bgcolor = #f7e5c6>Hangarage</td> <td bgcolor = #f7e5c6>Parking</td> <td bgcolor = #f7e5c6>Accommodation</td> <td bgcolor = #f7e5c6>School ?</td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> </tr> <tr> <td colspan="6"><p>Remarks:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="6"><p>Warnings:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="3"><p>Website: </p> <p> </p></td> <td colspan="3"><p>Operator:</p> <p> </p></td> </tr> <tr> <td colspan="6">Google Ifram Image</td> </tr> </table> </body> </html> -
Hi People. I am building a webform where users submit airfield data. It is stored in the database and all is well so far. However, on line 109 I say echo "Thank you, your airfield has been submitted"; I would like to say the following.... Thank you for submitting the airfield data, the resulting card will look like this... Then put "this completed form" into the page and not the "submitting form" Source code.... <!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 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"? 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 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); echo "Thank you, Your airfield has been submitted."; // Output what the form looks like // End of how the form looks } } //} ?> <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">Yes </option> <option value="No">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">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">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 = "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">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> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> Form to be inserted <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>{$height_above from DB}</td> <td bgcolor = #E6F8EB>{$mb_diff from DB}</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #f7e5c6>Runway Numbers</td> <td bgcolor = #f7e5c6>Circuit Direction</td> <td bgcolor = #f7e5c6>Circuit Height</td> <td bgcolor = #f7e5c6>Runway Length</td> <td bgcolor = #f7e5c6>Runway Surface</td> <td bgcolor = #f7e5c6>Food? </td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </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> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB><p> </p></td> </tr> <tr> <td bgcolor = #f7e5c6>Opperating Hrs</td> <td bgcolor = #f7e5c6>Maintenance</td> <td bgcolor = #f7e5c6>Hangarage</td> <td bgcolor = #f7e5c6>Parking</td> <td bgcolor = #f7e5c6>Accommodation</td> <td bgcolor = #f7e5c6>School ?</td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> </tr> <tr> <td colspan="6"><p>Remarks:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="6"><p>Warnings:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="3"><p>Website: </p> <p> </p></td> <td colspan="3"><p>Operator:</p> <p> </p></td> </tr> <tr> <td colspan="6">Google Ifram Image</td> </tr> </table>
-
Validated Input in drop down fields
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Thanks for your reply GuiltyGear. Sorry, I obviously wasn't clear with the explanation of what I am after. I want the "selected" value to stay the same when an error occurs by a user not filling in one of the other boxes. At the moment it does this.... [square brackets represent the input html box or input dropdown] input 1[user input1 textbox] input 2[user input2 textbox] If the user doesn't put "something" into the input box then it is captured and they get an error message telling them to put "something" into the box. We capture what they did put into the other input box with the variable and put it back in. However, I would like to do the same with the drop down box, here is the code that works for the input box. <input type='text' name='alternative' size = '40' maxlength='30' value = '<?php echo $alternative; ?>'> Here is the code from the selection drop down. <select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> And here is the code for the whole script <!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 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"? 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 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); echo "Thank you, Your airfield has been submitted."; // Output what the form looks like // End of how the form looks } } //} ?> <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">Yes </option> <option value="No">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">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">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 = "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">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> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> -
Hello people, thank you to everyone that has helped me on this forum. You have been terrific. I am submitting a form to a database and am having a small problem with the validation scripts. Basically if the user doesn't put something into one of the fields they get an error message. However, I am keeping the information already submitted in the input box with the following code <input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'> This is so that the user doesn't have to input the same data again if he forgot one box. How do I do the same for "drop down" boxes? Here is the code from the form for the "ppr" (aviation terms 'Prior Permission Required') <select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">No </option> </select> The problem I have is that there are quite a number of these drop down boxes on the form I have created. And it always goes back to the first "option value" when there is an error. I do have a variable for $ppr, please could someone tell me how to incorporate it so that the user doesn't have to select the correct option value all over again. Hope my explanation is clear. Thanks in advance.
-
Please help, submitting to DB when form not complete.
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Brilliant, thanks guys. Getting there slowly but surely. -
Hi people. I am building a web form and submitting the data to the DB when complete but I have 2 problems. 1. When the user misses something although the error is being captured and they are asked to enter the field that they are missing it is still being sent to the database and being stored. Please can someone tell me where the "die" or whatever should go in the code following. <!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 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"? 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 "Thank you, Your airfield has been submitted."; // Output what the form looks like // End of how the form looks } } //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); //} ?> <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">Yes </option> <option value="No">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">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">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 = "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">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> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> 2. If there is something missing then I have put values into the form from the variables with the following code <input type='text' name='username' size = '40' maxlength='30' value = '<?php echo $username; ?>'> and in the textareas with the following <textarea name= "remarks" input type = 'text' rows = "5" cols = "29" /><?php echo $remarks; ?></textarea> How do I do the same for drop down selection boxes? The value changes back to the "first one in the list" if the user misses a box out. Thanks in advance.
-
Trying to Validate Input, but it's not working
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Brilliant Pikachu2000 Sorted. Just one more thing. It is now showing the "Your data has been saved" message all the time the form is showing? Any idea how I can fix it? -
Trying to Validate Input, but it's not working
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
I've tried that by entering uncommenting out just the one validation and have changed it to what you said but it's still not working. With the code like this I get a blank screen. My commented out one above I can see the form when loaded on the website. <!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 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"? 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\""; else { die ("success!"); } } //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); echo "Your data has been saved"; } ?> <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'></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'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td><select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">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' /></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" /></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" /></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" /></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' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td><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">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' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td><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' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td><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' /></td> <td> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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" /></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" /></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" /></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" /></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" /></textarea></td> <td>700 x 700 pixels please.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> -
Hi People. I have a form which people will fill out, it then submits the data to the database. I have been following a video that showed me how to validate the form, however it's not working. In the following code I have /* commented out all of the validation code that isn't working /* Please could someone look at my code and tell me where I'm going wrong? <!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 /* 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"? 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\""; else { die ("success!"); } } */ //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); echo "Your data has been saved"; } ?> <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'></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'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td><select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">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' /></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" /></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" /></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" /></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' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td><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">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' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td><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' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td><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' /></td> <td> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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" /></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" /></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" /></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" /></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" /></textarea></td> <td>700 x 700 pixels please.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html>
-
Form Validation Data, where should I put it?
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Brilliant thanks -
Hello People. Firstly can I say thanks to everyone who has helped me so far with my microlight website. It is made for the members and your help is really appreciated. OK. So now I have the info in the database, submitted from a form. So now how do I get that information into the following table? Here is the PHP form... the 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 = "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']; if(isset($_POST['submit'])) { //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); echo "Your data has been saved"; } ?> <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'></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'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td><select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">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' /></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" /></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" /></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" /></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' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td><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">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' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td><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' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td><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' /></td> <td> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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" /></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" /></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" /></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" /></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" /></textarea></td> <td>700 x 700 pixels please.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> And here is the output card that will be shown on the site. <!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> <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>{$height_above from DB}</td> <td bgcolor = #E6F8EB>{$mb_diff from DB}</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #f7e5c6>Runway Numbers</td> <td bgcolor = #f7e5c6>Circuit Direction</td> <td bgcolor = #f7e5c6>Circuit Height</td> <td bgcolor = #f7e5c6>Runway Length</td> <td bgcolor = #f7e5c6>Runway Surface</td> <td bgcolor = #f7e5c6>Food? </td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </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> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB><p> </p></td> </tr> <tr> <td bgcolor = #f7e5c6>Opperating Hrs</td> <td bgcolor = #f7e5c6>Maintenance</td> <td bgcolor = #f7e5c6>Hangarage</td> <td bgcolor = #f7e5c6>Parking</td> <td bgcolor = #f7e5c6>Accommodation</td> <td bgcolor = #f7e5c6>School ?</td> </tr> <tr> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> <td bgcolor = #f7e5c6> </td> </tr> <tr> <td colspan="6"><p>Remarks:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="6"><p>Warnings:</p> <p> </p> <p> </p></td> </tr> <tr> <td colspan="3"><p>Website: </p> <p> </p></td> <td colspan="3"><p>Operator:</p> <p> </p></td> </tr> <tr> <td colspan="6">Google Ifram Image</td> </tr> </table> </body> </html> I would just like to know what PHP to put in so that it shows the below card after the user clicks the "Have It" button. I have put into {curly braces} what should go into the card. If someone would be kind enough to show me one, that will be enough for me to complete the rest. Thanks in advacne.
-
Hi people, thanks for your wonderful input so far, I am really learning with your help. I have been watching the following video teaching me some PHP and am looking at the form validation data. Please could you tell me where I would put this into the following file for it to work. <!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']; if(isset($_POST['submit'])) { //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); echo "Your data has been saved"; } ?> <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'></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'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td><select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">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' /></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" /></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" /></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" /></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' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td><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">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' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td><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' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td><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' /></td> <td> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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" /></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" /></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" /></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" /></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" /></textarea></td> <td>700 x 700 pixels please.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html>
-
How do I Incorporate these two files into one?
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Brilliant, thanks M8. Sorted. -
Hello you helpful people. Please can someone tell me how to incorporate these two working files into one? I am running Jumi in Joomla and it doesn't seem to want to load it as a script looking at two files. <!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 include "config.php"?> --> <form name = 'form1' method = 'post' action='config.php'> <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'></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'></td> <td>65 Ft</td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff' size = '40' maxlength='40'></td> <td>2 Mb</td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' size = '40' maxlength='30'></td> <td>Sherburn</td> </tr> <tr> <td> </td> <td>PPR?</td> <td><select name = "ppr"> <option value = "Yes">Yes </option> <option value="No">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' /></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" /></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" /></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" /></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' /></td> <td>1000 Ft</td> </tr> <tr> <td> </td> <td>Runway Length</td> <td><input type='text' name='runway_length' size = '40'maxlength='50' /></td> <td>500m</td> </tr> <tr> <td> </td> <td>Runway Surface</td> <td><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">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' /></td> <td>135.475</td> </tr> <tr> <td> </td> <td>Radio Callsign</td> <td><input type='text' name='radio_callsign' size = '40'maxlength='50' /></td> <td>Rufforth Traffic</td> </tr> <tr> <td> </td> <td>Radio Type</td> <td><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' /></td> <td>E.G. if close to MATZ etc</td> </tr> <tr> <td> </td> <td>Fuel</td> <td><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' /></td> <td> </td> </tr> <tr> <td> </td> <td>Operating Hours</td> <td><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">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">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">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">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">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" /></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" /></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" /></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" /></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" /></textarea></td> <td>700 x 700 pixels please.</td> </tr> <tr> <td><input type='submit' name='submit' value='Have-It' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> That is the input form, and the config.php file is as follows. (except the password obviously) <?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']; //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); ?> I am looking to combine both the above into one file and still send the information to the DB. Thanks in advance.
-
Hi Muddy_Funster Sorry I don't know what you mean about closing the braces round the INSERT values. everywhere I've got a ( I've got a corresponding ) as far as I can see. Sorry for being STUPID. All I have inserted is the "ppr" into the form which it two radio buttons for "Y" and "N" and then into the various places in the config01.php file. If you load the files and do a search for "ppr" then that's what I've inserted. Thanks for you help.
-
Hi People. Thanks to everyone that helped me yesterday with my file that finally connected to the database. However, I have added a new field to my DB and now get further problems. Here is the error message I am getting after I added the "ppr" stuff to both files. Please could someone look at my code and tell me where I'm going wrong. <!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 include "config01.php"?> <form name = 'form1' method = 'post' action='config01.php'> <table width="700" border="1" cellspacing="5" cellpadding="5"> <caption> Submit Your Airfield Details </caption> <tr> <td width="100"> </td> <td width="200">Your Name</td> <td width="200"><input type='text' name='username' maxlength='30'></td> <td width="100"> </td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above'maxlength= '30'></td> <td> </td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff'maxlength='40'></td> <td> </td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' maxlength='30'></td> <td> </td> </tr> <tr> <td> </td> <td>PPR</td> <td><input type='radio' name='ppr' value="Y"/> Yes <input type='radio' name='ppr' value="N" /> No</td> <td> </td> </tr> <tr> <td><input type='submit' name='submit' value='post' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> Then the code from config01.php <?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"]; //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()); /* $sql01 = "INSERT INTO users SET username = '$username',height_above = '$height_above', mb_diff = $mb_diff, alternative = $alternative"; $result=mysql_query($sql01); */ //mysql_query("INSERT INTO users VALUES ('$username','$height_above','$mb_diff','$alternative')"); //mysql_query("INSERT INTO users (username, height_above, mb_diff, alternative) VALUES ('$username', '$height_above', '$mb_diff', '$alternative'"); //$insert_query = "INSERT INTO users (username, height_above, mb_diff, alternative) VALUES ('$username', '$height_above', '$mb_diff', '$alternative')"; //$insert_action = mysql_query($insert_query) or die ('Error Dring Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); //mysql_query("INSERT INTO users VALUES ('$username','$height_above','$mb_diff','$alternative')"); CHANGES FOLLOW THIS LINE . . $query = "INSERT INTO users (username, height_above, mb_diff, alternative, ppr) VALUES ('$username', '$height_above', '$mb_diff', '$alternative', '$ppr'"; if( !$result = mysql_query($query) ) { echo "<br>Query: $query<br>Produced error: " . mysql_error() .'<br>'; } else { echo "Query ran and inserted " . mysql_affected_rows() . "row(s)."; } ?> I only added the one thing and I've gone and broken it already. It was working last night too.. :-(
-
Please help, trying to input data into DB driving me crazy.
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Thanks for that Pikachu2000. I've run a php_info on my server and it says that configuration file path can be located at /etc/php5/apache2 but when I look into this with filezilla I am told that it doesn't exist? Any ideas? -
Please help, trying to input data into DB driving me crazy.
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
One thing I haven't got though is any feedback. I see from your code there is supposed to be some feedback echo "Query ran and inserted " . mysql_affected_rows() . "row(s)."; I just got a blank page?????? Any ideas why? Because when I've finished this I really would like some feedback to the users. -
Please help, trying to input data into DB driving me crazy.
VinceGledhill replied to VinceGledhill's topic in PHP Coding Help
Muddy Funster. Thanks for your patience with this Thicko. I've done as you said and now it is "sort of" working. I am getting TWO rows inserted into the DB. One is a new user ID and everything else is empty. Then another row with what I put into the form??? Pikachu2000, Brilliant, thanks for your input, it's now Working as it should be. Result people thanks a bunch. I'll be back with more I'm sure. Hope one day to put something back. Like I am doing to my users at www.microlightforum.com and www.microlight.co On behalf of all my forum members, thanks guys. You've been brilliant with this THICKO. Regards VinceG