Yes, it can be written in a bit more elegant way - provided that there's no use for the case that value1 and value3 are set but not value2:
if(isset($_POST['submit']))
{
if(!empty($_POST['value1']))
{
if($_POST['value2'])
{
if($_POST['value3'])
{
}
else
{
}
}
else
{
}
}
}
If you (here or somewhere else) need to check some $_POST[..]-value in multiple if-statements I would recommend that you assign it to some variable to use that from that point on, which will make it a bit more easy to read. Example here for the case that it would actually make sense to check what I excluded above (value1 and value3 but not value2):
if(isset($_POST['submit']))
{
$value1empty = empty($_POST['value1']);
$value2empty = empty($_POST['value2']);
$value3empty = empty($_POST['value3']);
$value1only = !$value1empty && $value2empty && $value3empty;
$value1and2 = !$value1empty && !$value2empty && $value3empty;
$value1and3 = !$value1empty && $value2empty && !$value3empty;
$allValues = !$value1empty && !$value2empty && !$value3empty;
if($value1only)
{
}
elseif($value1and2)
{
}
}