For some reason my code is skipping couple of parts even though they seem correct. The code just executes the last header function. The problem seems to be of these headers. How to make this work?
<?php
$values = [
'orderperson',
'address',
'postnumber',
'city',
'phone',
'email'
];
$shipvalues = [
'recipient',
'address1',
'postnumber1',
'city1',
'phone1',
'email1'
];
foreach($values as $value) {
if(empty($_POST[$value])) {
header("Location: http://example.com?errors=true");
}
}
if (array_key_exists("checkbox", $_POST) && !empty($_POST['checkbox'])) {
foreach ($shipvalues as $shipvalue) {
if(empty($_POST[$shipvalue])) {
header("Location: http://example.com?errors=true");
}
}
}
header("Location: http://example.com");
exit;