Why does $validSave always contains FALSE even I click the btnEdit?
Here's the code:
$validSave = false;
if(isset($_POST['btnSearch'])){
if(isset($_POST['btnEdit']){
$validSave = true;
}
}
if(isset($_POST['btnSave']){
if($validSave){
... //Does not go here after I press the btnEdit
}
else{
echo "Unable to save"; //It always goes here
}
}
$validSave
always contains FALSE because if(isset($_POST['btnSearch']))
and if(isset($_POST['btnEdit'])
are false.if one condition is true and one condition is false then state will not change of $validSave
if you have two button if(isset($_POST['btnSearch']))
and if(isset($_POST['btnEdit'])
try to use like this
if(isset($_POST['btnSearch']) || isset($_POST['btnEdit'])){
$validSave = true;
}
or if you have one button and one field you need to try like that
if(isset($_POST['your button name'])){
$otherField=$_POST['btnSearch'];
$validSave = true;
}