I have a php booking form which checks to make sure that information has been entered in the boxes before its submitted:
I use the following to check to make sure group has a value in it.
if(!isset($_POST['group']) || trim($_POST['group']) == '')
{
$error.= "Group Size is required<br/>";
}
How can I use an IF statement too check that the value in group is greater than 39 but less than 400?
if(!empty($_POST['group']) && is_numeric($_POST['group']))
{
if($_POST['group'] < 400 && $_POST['group'] > 39)
{
//here you go
}
}
The empty also checks for existence. You should always check the type of the values youre getting, not only if empty - type casting gets done by php for you
Other answer is wrong btw, question is greater than 39, not greater or equal 39
Just do
if(strlen(trim($_POST['code'])) >= 39 && strlen(trim($_POST['code'])) < 400)