I can't figure out how to stop the undefined index if my form is submitted without data in it.
this is my submit.php code - any suggestions? I'm a total newb at php and a bit confused -
Thanks!
<?php
$dbc = mysqli_connect('localhost', 'root', '', 'jinx')
or die(mysqli_connect_error());
$name = mysqli_real_escape_string($dbc, strip_tags($_POST['name']));
$firsttime = mysqli_real_escape_string($dbc, strip_tags($_POST['firsttime']));
$date = mysqli_real_escape_string($dbc, strip_tags($_POST['date']));
$hour = mysqli_real_escape_string($dbc, strip_tags($_POST['hour']));
$time = mysqli_real_escape_string($dbc, strip_tags($_POST['time']));
$city = mysqli_real_escape_string($dbc, strip_tags($_POST['city']));
$flightnumber = mysqli_real_escape_string($dbc, strip_tags($_POST['flightnumber']));
$friendliness = mysqli_real_escape_string($dbc, strip_tags($_POST['friendliness']));
$luggage = mysqli_real_escape_string($dbc, strip_tags($_POST['luggage']));
$seating = mysqli_real_escape_string($dbc, strip_tags($_POST['seating']));
$cleanliness = mysqli_real_escape_string($dbc, strip_tags($_POST['cleanliness']));
$noiselvl = mysqli_real_escape_string($dbc, strip_tags($_POST['noiselvl']));
// build up your query string
$ins_query = "INSERT INTO jinxsurvey (name, firsttime, date, hour, time, city, flightnumber, friendliness, luggage, seating, cleanliness, noiselvl) " .
"VALUES (" .
"'" . $name . "', " .
"'" . $firsttime . "', " .
"'" . $date . "', " .
"'" . $hour . "', " .
"'" . $time . "', " .
"'" . $city . "', " .
"'" . $flightnumber . "', " .
"'" . $friendliness . "', " .
"'" . $luggage . "', " .
"'" . $seating . "', " .
"'" . $cleanliness . "', " .
"'" . $noiselvl . "'" .
")";
// execute the query
$result = mysqli_query($dbc, $ins_query)
or die("Could not submit the data: " . mysqli_error($dbc));
// close the database connection
mysqli_close($dbc);
?>