Hi Guys.
I have a form with 5 input fields
if i fill out all the inputs it works ok
however if i fill out only say 3 inputs i then get a php warning A non-numeric value encountered on the inputs i have not filled out ?
my php version is 7.3
My code
Blockquote
if(isset($_POST["date"])){
$date =($_POST["date"]);
}
if(isset($_POST["totalvalue"])){
$totalvalue =($_POST["totalvalue"]);
}
if(isset($_POST["code1"])){
$code1 =($_POST["code1"]);
}
if(isset($_POST["name1"])){
$name1 =($_POST["name1"]);
}
if(isset($_POST["price1"])){
$price1 =($_POST["price1"]);
}
if(isset($_POST["amount"])){
$amount =($_POST["amount"]);
}
if(isset($_POST["quantity1"])){
$quantity1 =($_POST["quantity1"]);
}
if(isset($_POST["total"])){
$total =($_POST["total"]);
}
if(isset($_POST["contact1"])){$contact1 =($_POST["contact1"]);}
if(isset($_POST["contact2"])){$contact2 =($_POST["contact2"]);}
if(isset($_POST["contact3"])){$contact3 =($_POST["contact3"]);}
if(isset($_POST["contact4"])){$contact4 =($_POST["contact4"]);}
if(isset($_POST["contact5"])){$contact5 =($_POST["contact5"]);}
if(isset($_POST["depot"])){$depot =($_POST["depot"]);}
if(isset($_POST["name"])){$name =($_POST["name"]);}
if(isset($_POST["contact"])){$contact =($_POST["contact"]);}
if(isset($_POST["email"])){$email =($_POST["email"]);}
if(isset($_POST["vatband1"])){$vatband1 =($_POST["vatband1"]);}
if(isset($_POST["code2"])){$code2 =($_POST["code2"]);}
if(isset($_POST["name2"])){$name2 =($_POST["name2"]);}
if(isset($_POST["price2"])){$price2 =($_POST["price2"]);}
if(isset($_POST["quantity2"])){$quantity2 =($_POST["quantity2"]);}
if(isset($_POST["vatband2"])){$vatband2 =($_POST["vatband2"]);}
if(isset($_POST["code3"])){$code3 =($_POST["code3"]);}
if(isset($_POST["name3"])){$name3 =($_POST["name3"]);}
if(isset($_POST["price3"])){$price3 =($_POST["price3"]);}
if(isset($_POST["quantity3"])){$quantity3 =($_POST["quantity3"]);}
if(isset($_POST["vatband3"])){$vatband3 =($_POST["vatband3"]);}
if(isset($_POST["code4"])){$code4 =($_POST["code4"]);}
if(isset($_POST["name4"])){$name4 =($_POST["name4"]);}
if(isset($_POST["price4"])){$price4 =($_POST["price4"]);}
if(isset($_POST["quantity4"])){$quantity4 =($_POST["quantity4"]);}
if(isset($_POST["vatband4"])){$vatband4 =($_POST["vatband4"]);}
if(isset($_POST["code5"])){$code5 =($_POST["code5"]);}
if(isset($_POST["name5"])){$name5 =($_POST["name5"]);}
if(isset($_POST["price5"])){$price5 =($_POST["price5"]);}
if(isset($_POST["quantity5"])){$quantity5 =($_POST["quantity5"]);}
if(isset($_POST["vatband5"])){$vatband5 =($_POST["vatband5"]);}
if(isset($_POST["sum1"])){$sum1 =($_POST["sum1"]);}
if(isset($_POST["sum2"])){$sum2 =($_POST["sum2"]);}
if(isset($_POST["sum3"])){$sum3 =($_POST["sum3"]);}
if(isset($_POST["sum4"])){$sum4 =($_POST["sum4"]);}
if(isset($_POST["sum5"])){$sum5 =($_POST["sum5"]);}
$sum1=$quantity1*$price1;
$sum2=$quantity2*$price2;
$sum3=$quantity3*$price3;
$sum4=$quantity4*$price4;
$sum5=$quantity5*$price5;
$total=$sum1+$sum2+$sum3+$sum4+$sum5;
if($sum1!=0){
$sum1 = number_format($sum1, 2, '.', '');
}
else{
$sum1 = "";
}
if($sum2!=0){
$sum2 = number_format($sum2, 2, '.', '');
}
else{
$sum2 = "";
}
if($sum3!=0){
$sum3 = number_format($sum3, 2, '.', '');
}
else{
$sum3 = "";
}
if($sum4!=0){
$sum4 = number_format($sum4, 2, '.', '');
}
else{
$sum4 = "";
}
if($sum5!=0){
$sum5 = number_format($sum5, 2, '.', '');
}
else{
$sum5 = "";
}
$net = number_format($net, 2, '.', '');
$vat = number_format($vat, 2, '.', '');
$total = number_format($total, 2, '.', '');
any advice thanks !