I have a form as follows.
These is an input called ‘boxes’ which should contain the total of 4 other inputs (‘large’, ‘medium’, ‘small’ and ‘tails’).
Before I update mySQL data I want to check the following:
boxes = (large + medium + small + tails)
Here is part of the code I am using without success:
[CODE]
if (isset($_POST[‘submit’])){
$boxes = $_POST[“boxes”];
$large = $_POST[“large”];
$medium = $_POST[“medium”];
$smalll = $_POST[“small”]; // smalll becasue small is a keyword
$tails = $_POST[“tails”];
$message = NULL;
if (empty($_POST[‘boxes’])) {
$boxes = FALSE;
$message .= ‘<p>You forgot to enter boxes!</p>’;
}else{
$boxes = $_POST[‘boxes’];
}
$totalBoxes = $large + $medium + $smalll + $tails;
if( $totalBoxes <> $boxes){
$message = ‘<p>The number of boxes does not add up!</p>’;
$totalBoxes = FALSE;
}
if ($boxes && $totalBoxes) {
require (‘cgi-bin/mysql_connect.php’); //connect to the db
$queryDate = sprintf(“%04d-%02d-%02d”, $year, $month, $day);
$sql = “UPDATE vessels SET boxes = ‘$boxes’, large=’$large’, medium=’$medium’, small=’$smalll’, tails=’$tails’, boxweight =’$boxweight’, dipped = ‘$dipped’, dateLanded = ‘$queryDate’ WHERE id=$id”;
$result = mysql_query($sql);
header(“Location: vessels.php”);
mysql_close(); // Close the database connection.
}
}
The problem is this:
Even when I put 100 into boxes, 50 into large, 10 into medium, 10 into small and 30 into tails it still says ‘Totals do not add up”
Can anyone advise why it is not working?
THanks,
J