Hey all
Can you give me advice on this statement i have made… it doesn’t work like i want it too. but from what i see it makes sense
if ($_GET[‘additem’] == ‘yes’) {
$productid = $_GET[‘pid’];
$pdescript = $_GET[‘pdesc’];
$tblname = $_GET[‘tblname’];
$phead = $_GET[‘phead’];
$price = $_GET[‘price’];
if ($productid == ‘’) {
$response = 1;
}
Else if ($pdescript == ‘’) {
$response = 1;
}
Else if ($tblname == ‘’) {
$response = 1;
}
Else if ($phead == ‘’) {
$response = 1;
}
Else if ($price == ‘’) {
$response = 1;
}
Else if ($img == ‘’) {
$response = 1;
}
ELSE {
$response = 0;
}
}
it’s for a loop and validation checking.
when they post. it loops onto the same page with $_SERVER[‘PHP_SELF’]
the form method is get. and it is checking if any of the fields are blank. (hence the big IF statement). if any of the fields are blank. it should activate $response = 1;
and if ($response == 1) {
echo ‘You left a Required field blank.’;
}
ELSE {
(mysql update query etc…)
}
but even when i have all the fields entered… it still makes $response = 1;
and then displays that message…
can anyone shed some light?
it is an IF statement inside an IF statement. i don’t know if that works but it made logical sense to me.
i.e. check if $_GET[‘additem’] = true then check if any of the fields have been left blank.
thanks in advance
Brendan