I am new to php and this is my first post here, so new to writing post also. I am using a script to vaidate a form input. Part of the script is as below:
$data=$_POST;
print_r($data);
if(($data['dm']="No") and (!empty($data['dmsince']))):
$error=$error." dm mismatch N";
endif;
if(($data['dm']="Yes") and (empty($data['dmsince']))):
$error=$error." dm mismatch Y";
endif;
if ($error):
print $error;
$error="";
print $form;
else:
print "OK";
I am accepting $_POST['dm'] through select statement either as yes or no.
The problem that occurs is when the form is processed:
$_POST['dm']='No' and $_POST['dmsince'] is blank.
I get error as 'dm mismatch Y'.
$_POST['dm']=Yes and $_POST['dmsince']='some valid date'
I get error as 'dm mismatch N'.
Logically in both these cases I should not get any error. It appears that it is entering one of the loops forcibly. I have also tried with elseif with no result. What is wrong with this code?
$data['dm']=="No"and use{}bracketsif(2 > 1) { ... }else{ ... }