单击提交时,某些文本框变为空白

On my webpage when you click on submit to submit the form several text boxes suddenly become blank after clicking submit and so the data fails to be inputted into the database. I get this error appearing:

string(0) "" Incorrect integer value: '' for column 'TotalProfit' at row 1

I know why it says "string(0) "" " and that is because it is dumping the variable $TruckDamagePost but because the text box goes blank it tries to submit it as blank.

The textboxes that become blank are: total-profit late-fee fines-cost travel-expenses fuel-cost truck-damage cargo-damage

Here is my HTML Code for the webpage:

<head>

    <!-- Appears in the title bar in web browser -->
    <title>JWT Haulage Group Drivers Area</title>

    <meta name="description" content="JWT Haulage Group Ltd is a virtual trucking company for Euro Truck Simulator 2, UK and 
    German Truck Simulator. We have over 600 drivers registered already.">                            <!-- Meta Stuff Required -->

    <meta name="keywords" content="JWT, JWT Haulage, JWT Haulage Group, JWT Haulage Ltd, Euro Truck Simulator 2, ETS2, 
    UK Truck Simulator, UKTS, German Truck Simulator, GTS, Virtual Trucking Company, VTC">

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />                             <!-- Meta Stuff Required -->

    <link rel="stylesheet" type="text/css" href="styles.css" />                                       <!-- CSS -->

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>               <!-- JQuery -->

    <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-37114333-2']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>

    <script>
     $(function() {
    if(!$.support.placeholder) { 
        var active = document.activeElement;
        $(':text').focus(function () {
            if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
                $(this).val('').removeClass('hasPlaceholder');
            }
        }).blur(function () {
            if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
            }
        });
        $(':text').blur();
        $(active).focus();
        $('form').submit(function () {
            $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
        });
    }
});
    </script>

    <script>
    var error = "";
    error = "<?=$error?>";
    var spError = error.split("|");
    for(var i=0; i<spError.length;i++){
        $('.jwtinternational-application').append("<p class='error'>"+spError[i]+"<br/></p>");
        //alert(spError[i]);
    }   
    </script>

    <SCRIPT language=Javascript>
       <!--
       function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode;
          if (charCode != 46 && charCode > 31
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       }
       //-->

    </SCRIPT>

</head>

<h4>JWT Log Form</h4>
<h4>WARNING: do not use the below form as it is currently being worked on</h4>
 The following form can be used to log your loads for JWT in ETS2.<br>
 If one of the fields do not apply to your load just put £0 or N/A.<br>
<form name="jwtinternational-application-form" class='jwtinternational-application-form' action="drivers-log-send.php" method="post">
    <div class='jwtinternational-application-left'>
        <input type="text" class="text-box" name="forum-name" placeholder="Registered Forum Name"/><br>
        <input type="text" class="text-box" name="driver-number" placeholder="Driver Number"/><br>
        <input type="text" class="text-box" name="email-address" placeholder="Email Address"/><br>
        <div>
             What division in ETS2 are you driving for?<br>
            <select id="dropdown1" name="dropdown1" class="text-box">
                <option value="">Please Select....</option>
                <option value="International">International</option>
                <option value="Samcro">Samcro Transport</option>
                <option value="Port">Port Logistics</option>
                <option value="Bio">Bio-Fuels</option>
                <option value="WnD">Wagon 'n' Drag</option>
            </select>
            <br>
        </div>
        <input type="text" class="text-box" name="truck-driving" placeholder="Truck Driving"/><br>
        <input type="text" class="text-box" name="cargo" placeholder="Cargo"/><br>
        <br>
        <input type="text" class="text-box" name="depot-leaving" placeholder="Depot Leaving"/><br>
        <input type="text" class="text-box" name="city-leaving" placeholder="City Leaving"/><br>
        <input type="text" class="text-box" name="country-start" placeholder="Country Starting In"/><br>
        <div>
             Day Start:<br>
            <select id="dropdown2" name="dropdown2" class="text-box">
                <option value="">Please Select....</option>
                <option value="Monday">Monday</option>
                <option value="Tuesday">Tuesday</option>
                <option value="Wednesday">Wednesday</option>
                <option value="Thursday">Thursday</option>
                <option value="Friday">Friday</option>
                <option value="Saturday">Saturday</option>
                <option value="Sunday">Sunday</option>
            </select>
            <br>
        </div>
        <div>
             Time Start:<br>
            <input type="time" class="text-box" name="time-start"/><br>
        </div>
        <input type="text" class="text-box" name="mileage-start" placeholder="Mileage Start" onkeypress="return isNumberKey(event)"/><br>
        <br>
        <input type="text" class="text-box" name="depot-arriving" placeholder="Depot Arriving"/><br>
        <input type="text" class="text-box" name="city-arriving" placeholder="City Arriving"/><br>
        <input type="text" class="text-box" name="country-end" placeholder="Country Finishing In"/><br>
        <div>
             Day End:<br>
            <select id="dropdown3" name="dropdown3" class="text-box">
                <option value="">Please Select....</option>
                <option value="Monday">Monday</option>
                <option value="Tuesday">Tuesday</option>
                <option value="Wednesday">Wednesday</option>
                <option value="Thursday">Thursday</option>
                <option value="Friday">Friday</option>
                <option value="Saturday">Saturday</option>
                <option value="Sunday">Sunday</option>
            </select>
            <br>
        </div>
        <div>
             Time End:<br>
            <input type="time" class="text-box" name="time-end" placeholder="Time End"/><br>
        </div>
        <input type="text" class="text-box" name="mileage-end" placeholder="Mileage End" onkeypress="return isNumberKey(event)"/><br>
        <div>
             Cargo Damage:<br>
             &pound;&nbsp;<input type="text" class="text-box" name="cargo-damage" onkeypress="return isNumberKey(event)"/><br>
        </div>
        <div>
             Truck Damage:<br>
             &pound;&nbsp;<input type="text" class="text-box" name="truck-damage" onkeypress="return isNumberKey(event)"/><br>
        </div>
        <div>
             Fuel Cost:<br>
             &pound;&nbsp;<input type="text" class="text-box" name="fuel-cost" onkeypress="return isNumberKey(event)"/><br>
            <br>
        </div>
        <input type="text" class="text-box" name="fuel-amount" placeholder="Fuel Amount (Litres)" onkeypress="return isNumberKey(event)"/><br>
        <div>
             Travel Expenses (Ferry,Toll,Channel Tunnel):<br>
             &pound;&nbsp;<input type="text" class="text-box" name="travel-expenses" onkeypress="return isNumberKey(event)"/><br>
        </div>
        <div>
             Total Cost of Fines:<br>
             &pound;&nbsp;<input type="text" class="text-box" name="fines-cost" onkeypress="return isNumberKey(event)"/><br>
            <br>
        </div>
        <input type="text" class="text-box" name="on-time-or-late" placeholder="On Time/Late"/><br>
        <div>
             Late Fee:<br>
             &pound;&nbsp;<input type="text" class="text-box" name="late-fee" onkeypress="return isNumberKey(event)"/><br>
        </div>
        <div>
             Total Profit:<br>

And here is my PHP Code which sends the whole form to an email address and sends the data in the text-boxes which become blank to a database. That data is underneath "///PHP TO INSERT DRIVER'S BANK DETAILS INTO BANK DATABASE":

<?php
///PHP TO INSERT DRIVER'S BANK DETAILS INTO BANK DATABASE
session_start();
$host     = ""; // Host name
$username = ""; // Mysql username
$password = ""; // Mysql password
$db_name  = ""; // Database name
$tbl_name = "jwtdriversbank"; // Table name
$un       = "";
$usrname  = "";
$usrpass  = "";
$userID   = "";
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name") or die("cannot select DB");
if (isset($_SESSION['usrName'])) {
    $usrname = $_SESSION['usrName'];
} else {
    echo "4";
}
//var_dump ($usrname);
if (isset($_SESSION['usrPass'])) {
    $usrpass = $_SESSION['usrPass'];
} else {
    echo "5";
}
$sql    = "SELECT * FROM jwtdrivers WHERE username='$usrname' and password='$usrpass'";
$result = mysql_query($sql);
$rows   = mysql_fetch_array($result);
$userID = $rows['id'];
//var_dump ($userID);
if ($userID == "") {
    echo "3";
} else {
    $TotalProfitPost    = $TotalProfit;
    $LateFeePost        = $LateFee;
    $FinesCostPost      = $FinesCost;
    $TravelExpensesPost = $TravelExpenses;
    $FuelCostPost       = $FuelCost;
    $CargoDamagePost    = $CargoDamage;
    $TruckDamagePost    = $TruckDamage;
    var_dump($TruckDamagePost);
    $sql    = "INSERT INTO $tbl_name (DriverID, TotalProfit, LateFee, FinesCost, TravelExpenses, FuelCost, CargoDamage, TruckDamage)VALUES('$userID','$TotalProfitPost','$LateFeePost','$FinesCostPost','$TravelExpensesPost','$FuelCostPost','$CargoDamagePost',
            '$TruckDamagePost')";
    $result = mysql_query($sql);
    if ($result) {
    } else {
        die(mysql_error());
    }
}
?>

I think when submitting the form the hasPlaceholder class is getting applied. So when submitting the form the values are getting empty.

        $('form').submit(function () {
            $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
        });

On blur event the hasPlaceholder is getting applied to the text boxes. So the when submitting the form the input with class hasPlaceholder is emptying the value. So on form submission the values are not obtained in the server side.

.blur(function () {
            if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
                $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
            }
        });

Update: Try replacing

        $('form').submit(function () {
            $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
        });

to

          $('form').submit(function () {
                $(this).find('.hasPlaceholder').each(function() {
                    //$(this).val(''); 
                });
            });

in your code and check if the values are getting inserted.

First of all - you do not access the POST/GET data in your php at all.

For example:

$TruckDamagePost    = $TruckDamage;

This should be changed to:

$TruckDamagePost    = $_POST['TruckDamage'];

The second problem is that you use different names in HTML than the variables in your php. For the above variable you have the following HTML:

<input .... name="truck-damage" .... />

You have to change your HTML to <input .... name="TruckDamage" .... /> or modify your php code to $TruckDamagePost = $_POST['truck-damage']; (of course you have to inspect all your form / php code, not only the TruckDamage field/variable)

I can't tell if it will make your code working as you want to but certainly this is something that has to be corrected in the first place.