I'm setting up a form and want to check if some conditions are met when
the form submits. If they aren't, the form displays a missing field
message and the user has to go back to fill in the missing data. If it
is met, the form continues processing. I have the $state variable coming
from a drop down SELECT option with "" being the SELECTED default.
The if statements are included inside the form tags on the form page,
not on the processing page.
<?php
if (isset($state)) { //if state is set, require the following fields
?>
<input type="hidden" name="require"
value="name,add ress,city,state ,zipcode,phone, email,question" >
<?php
}
if (!isset($state) ) { //if state is not set, require the following fields
?>
<input type="hidden" name="require"
value="name,add ress,city,count ry,zipcode,phon e,email,questio n">
<?php
}
These both work properly. But where I'm running into trouble is when I
want to further define the if statement to contain like:
if ((!isset($state )) && ($country == "USA")) {
?>
<input type="hidden" name="require"
value="name,add ress,city,state ,zipcode,phone, email,question" >
<?php
}
This doesn't work. It will allow the empty $state and the value "USA" in
$country to submit. How can I prevent this?
the form submits. If they aren't, the form displays a missing field
message and the user has to go back to fill in the missing data. If it
is met, the form continues processing. I have the $state variable coming
from a drop down SELECT option with "" being the SELECTED default.
The if statements are included inside the form tags on the form page,
not on the processing page.
<?php
if (isset($state)) { //if state is set, require the following fields
?>
<input type="hidden" name="require"
value="name,add ress,city,state ,zipcode,phone, email,question" >
<?php
}
if (!isset($state) ) { //if state is not set, require the following fields
?>
<input type="hidden" name="require"
value="name,add ress,city,count ry,zipcode,phon e,email,questio n">
<?php
}
These both work properly. But where I'm running into trouble is when I
want to further define the if statement to contain like:
if ((!isset($state )) && ($country == "USA")) {
?>
<input type="hidden" name="require"
value="name,add ress,city,state ,zipcode,phone, email,question" >
<?php
}
This doesn't work. It will allow the empty $state and the value "USA" in
$country to submit. How can I prevent this?
Comment