error parsing - returning wrong error.
Posted: Mon Oct 30, 2006 11:57 am
ive created a simple function to check whether the fields in a submitted form are empty and also that some of them are of the correct format:
ive tested this by entering some test data, all valid except for inputting a string instead of an integer in the StockLevel textfield but instead of getting the format error, i get the empty field error and im having a hard time correcting it.
Code: Select all
function checkFields($productName, $productDesc, $unitPrice, $stockLevel){
//Check for empty fields
if(empty($productName) || empty($productDesc) || empty($unitPrice) || empty($stockLevel)){
header ("location: ../add_product.php?error=1");
exit;
}
//Check formats
if(!is_double($unitPrice)){
header ("loation: ../add_product.php?error=2");
exit;
}
if(!is_integer($stockLevel)){
header ("loation: ../add_product.php?error=3");
exit;
}
}