connect_errno > 0) { die('Unable to connect to database [' . $db->connect_error . ']'); } mysqli_report(MYSQLI_REPORT_ERROR); //Prepare prerequisites $created = time(); $ip = $SERVER['REMOTE_ADDR']; $POST = array_map('mysql_real_escape_string',$POST); if(isset($POST['submit'])) { //get the form data $EmployeeName = htmlentities($POST['EmployeeName'], ENT_QUOTES); $EmployeeRef = htmlentities($POST['EmployeeRef'], ENT_QUOTES); $WeeksPerYear = htmlentities($POST['WeeksPerYear'], ENT_QUOTES); $MonTownFrom = htmlentities($POST['MonTownFrom'], ENT_QUOTES); $MonPostcodeFrom = htmlentities($POST['MonPostcodeFrom'], ENT_QUOTES); $MonTownTo = htmlentities($POST['MonTownTo'], ENT_QUOTES); $MonPostcodeTo = htmlentities($POST['MonPostcodeTo'], ENT_QUOTES); $MonMiles = htmlentities($POST['MonMiles'], ENT_QUOTES); $TueTownFrom = htmlentities($POST['TueTownFrom'], ENT_QUOTES); $TuePostcodeFrom = htmlentities($POST['TuePostcodeFrom'], ENT_QUOTES); $TueTownTo = htmlentities($POST['TueTownTo'], ENT_QUOTES); $TuePostcodeTo = htmlentities($POST['TuePostcodeTo'], ENT_QUOTES); $TueMiles = htmlentities($POST['TueMiles'], ENT_QUOTES); $WedTownFrom = htmlentities($POST['WedTownFrom'], ENT_QUOTES); $WedPostcodeFrom = htmlentities($POST['WedPostcodeFrom'], ENT_QUOTES); $WedTownTo = htmlentities($POST['WedTownTo'], ENT_QUOTES); $WedPostcodeTo = htmlentities($POST['WedPostcodeTo'], ENT_QUOTES); $WedMiles = htmlentities($POST['WedMiles'], ENT_QUOTES); $ThuTownFrom = htmlentities($POST['ThuTownFrom'], ENT_QUOTES); $ThuPostcodeFrom = htmlentities($POST['ThuPostcodeFrom'], ENT_QUOTES); $ThuTownTo = htmlentities($POST['ThuTownTo'], ENT_QUOTES); $ThuPostcodeTo = htmlentities($POST['ThuPostcodeTo'], ENT_QUOTES); $ThuMiles = htmlentities($POST['ThuMiles'], ENT_QUOTES); $FriTownFrom = htmlentities($POST['FriTownFrom'], ENT_QUOTES); $FriPostcodeFrom = htmlentities($POST['FriPostcodeFrom'], ENT_QUOTES); $FriTownTo = htmlentities($POST['FriTownTo'], ENT_QUOTES); $FriPostcodeTo = htmlentities($POST['FriPostcodeTo'], ENT_QUOTES); $FriMiles = htmlentities($POST['FriMiles'], ENT_QUOTES); $SatTownFrom = htmlentities($POST['SatTownFrom'], ENT_QUOTES); $SatPostcodeFrom = htmlentities($POST['SatPostcodeFrom'], ENT_QUOTES); $SatTownTo = htmlentities($POST['SatTownTo'], ENT_QUOTES); $SatPostcodeTo = htmlentities($POST['SatPostcodeTo'], ENT_QUOTES); $SatMiles = htmlentities($POST['SatMiles'], ENT_QUOTES); $SunTownFrom = htmlentities($POST['SunTownFrom'], ENT_QUOTES); $SunPostcodeFrom = htmlentities($POST['SunPostcodeFrom'], ENT_QUOTES); $SunTownTo = htmlentities($POST['SunTownTo'], ENT_QUOTES); $SunPostcodeTo = htmlentities($POST['SunPostcodeTo'], ENT_QUOTES); $SunMiles = htmlentities($POST['SunMiles'], ENT_QUOTES); $SumMiles = htmlentities($POST['SumMiles'], ENT_QUOTES); $MonCheck = htmlentities($POST['MonCheck'], ENT_QUOTES); $TueCheck = htmlentities($POST['TueCheck'], ENT_QUOTES); $WedCheck = htmlentities($POST['WedCheck'], ENT_QUOTES); $ThuCheck = htmlentities($POST['ThuCheck'], ENT_QUOTES); $FriCheck = htmlentities($POST['FriCheck'], ENT_QUOTES); $SatCheck = htmlentities($POST['SatCheck'], ENT_QUOTES); $SunCheck = htmlentities($POST['SunCheck'], ENT_QUOTES); $MonHours = htmlentities($POST['MonHours'], ENT_QUOTES); $TueHours = htmlentities($POST['TueHours'], ENT_QUOTES); $WedHours = htmlentities($POST['WedHours'], ENT_QUOTES); $ThuHours = htmlentities($POST['ThuHours'], ENT_QUOTES); $FriHours = htmlentities($POST['FriHours'], ENT_QUOTES); $SatHours = htmlentities($POST['SatHours'], ENT_QUOTES); $SunHours = htmlentities($POST['SunHours'], ENT_QUOTES); $SumHours = htmlentities($POST['SumHours'], ENT_QUOTES); $MonTravel = htmlentities($POST['MonTravel'], ENT_QUOTES); $TueTravel = htmlentities($POST['TueTravel'], ENT_QUOTES); $WedTravel = htmlentities($POST['WedTravel'], ENT_QUOTES); $ThuTravel = htmlentities($POST['ThuTravel'], ENT_QUOTES); $FriTravel = htmlentities($POST['FriTravel'], ENT_QUOTES); $SatTravel = htmlentities($POST['SatTravel'], ENT_QUOTES); $SunTravel = htmlentities($POST['SunTravel'], ENT_QUOTES); $MonMealCheck = htmlentities($POST['MonMealCheck'], ENT_QUOTES); $TueMealCheck = htmlentities($POST['TueMealCheck'], ENT_QUOTES); $WedMealCheck = htmlentities($POST['WedMealCheck'], ENT_QUOTES); $ThuMealCheck = htmlentities($POST['ThuMealCheck'], ENT_QUOTES); $FriMealCheck = htmlentities($POST['FriMealCheck'], ENT_QUOTES); $SatMealCheck = htmlentities($POST['SatMealCheck'], ENT_QUOTES); $SunMealCheck = htmlentities($POST['SunMealCheck'], ENT_QUOTES); $MonEveningMealCheck = htmlentities($POST['MonEveningMealCheck'], ENT_QUOTES); $TueEveningMealCheck = htmlentities($POST['TueEveningMealCheck'], ENT_QUOTES); $WedEveningMealCheck = htmlentities($POST['WedEveningMealCheck'], ENT_QUOTES); $ThuEveningMealCheck = htmlentities($POST['ThuEveningMealCheck'], ENT_QUOTES); $FriEveningMealCheck = htmlentities($POST['FriEveningMealCheck'], ENT_QUOTES); $SatEveningMealCheck = htmlentities($POST['SatEveningMealCheck'], ENT_QUOTES); $SunEveningMealCheck = htmlentities($POST['SunEveningMealCheck'], ENT_QUOTES); $MonOvernightCheck = htmlentities($POST['MonOvernightCheck'], ENT_QUOTES); $TueOvernightCheck = htmlentities($POST['TueOvernightCheck'], ENT_QUOTES); $WedOvernightCheck = htmlentities($POST['WedOvernightCheck'], ENT_QUOTES); $ThuOvernightCheck = htmlentities($POST['ThuOvernightCheck'], ENT_QUOTES); $FriOvernightCheck = htmlentities($POST['FriOvernightCheck'], ENT_QUOTES); $SatOvernightCheck = htmlentities($POST['SatOvernightCheck'], ENT_QUOTES); $SunOvernightCheck = htmlentities($POST['SunOvernightCheck'], ENT_QUOTES); $DeclarationCheck = htmlentities($POST['DeclarationCheck'], ENT_QUOTES); $ip = htmlentities($POST['ip'], ENT_QUOTES); $created = htmlentities($_POST['created'], ENT_QUOTES); //check that the required fields are not empty if ($EmployeeName == '' || $EmployeeRef == '' || $DeclarationCheck == '') { $error = 'ERROR: Please fill in all required fields!'; renderForm($EmployeeName, $EmployeeRef, $DeclarationCheck, $error); } else { //Insert the new record if ($stmt = $mysqli->prepare("INSERT mileageform (EmployeeName,EmployeeRef,WeeksPerYear,MonTownFrom,MonPostcodeFrom,MonTownTo,MonPostcodeTo,MonMiles,TueTownFrom,TuePostcodeFrom,TueTownTo,TuePostcodeTo,TueMiles,WedTownFrom,WedPostcodeFrom,WedTownTo,WedPostcodeTo,WedMiles,ThuTownFrom,ThuPostcodeFrom,ThuTownTo,ThuPostcodeTo,ThuMiles,FriTownFrom,FriPostcodeFrom,FriTownTo,FriPostcodeTo,FriMiles,SatTownFrom,SatPostcodeFrom,SatTownTo,SatPostcodeTo,SatMiles,SunTownFrom,SunPostcodeFrom,SunTownTo,SunPostcodeTo,SunMiles,SumMiles,MonCheck,TueCheck,WedCheck,ThuCheck,FriCheck,SatCheck,SunCheck,MonHours,TueHours,WedHours,ThuHours,FriHours,SatHours,SunHours,SumHours,MonTravel,TueTravel,WedTravel,ThuTravel,FriTravel,SatTravel,SunTravel,MonMealCheck,TueMealCheck,WedMealCheck,ThuMealCheck,FriMealCheck,SatMealCheck,SunMealCheck,MonEveningMealCheck,TueEveningMealCheck,WedEveningMealCheck,ThuEveningMealCheck,FriEveningMealCheck,SatEveningMealCheck,SunEveningMealCheck,MonOvernightCheck,TueOvernightCheck,WedOvernightCheck,ThuOvernightCheck,FriOvernightCheck,SatOvernightCheck,SunOvernightCheck,DeclarationCheck,ip,created) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("ss", $EmployeeName, $EmployeeRef, $WeeksPerYear, $MonTownFrom, $MonPostcodeFrom, $MonTownTo, $MonPostcodeTo, $MonMiles, $TueTownFrom, $TuePostcodeFrom, $TueTownTo, $TuePostcodeTo, $TueMiles, $WedTownFrom, $WedPostcodeFrom, $WedTownTo, $WedPostcodeTo, $WedMiles, $ThuTownFrom, $ThuPostcodeFrom, $ThuTownTo, $ThuPostcodeTo, $ThuMiles, $FriTownFrom, $FriPostcodeFrom, $FriTownTo, $FriPostcodeTo, $FriMiles, $SatTownFrom, $SatPostcodeFrom, $SatTownTo, $SatPostcodeTo, $SatMiles, $SunTownFrom, $SunPostcodeFrom, $SunTownTo, $SunPostcodeTo, $SunMiles, $SumMiles, $MonCheck, $TueCheck, $WedCheck, $ThuCheck, $FriCheck, $SatCheck, $SunCheck, $MonHours, $TueHours, $WedHours, $ThuHours, $FriHours, $SatHours, $SunHours, $SumHours, $MonTravel, $TueTravel, $WedTravel, $ThuTravel, $FriTravel, $SatTravel, $SunTravel, $MonMealCheck, $TueMealCheck, $WedMealCheck, $ThuMealCheck, $FriMealCheck, $SatMealCheck, $SunMealCheck, $MonEveningMealCheck, $TueEveningMealCheck, $WedEveningMealCheck, $ThuEveningMealCheck, $FriEveningMealCheck, $SatEveningMealCheck, $SunEveningMealCheck, $MonOvernightCheck, $TueOvernightCheck, $WedOvernightCheck, $ThuOvernightCheck, $FriOvernightCheck, $SatOvernightCheck, $SunOvernightCheck, $DeclarationCheck, $ip, $created); $stmt->execute(); $stmt->close(); } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement. Your Mileage form has not been submitted successfully."; } } } else { renderForm(); } //declare in the order variable $mysqli->close(); ?>