Use the mb_strlen
to know how many characters it has and compare with the minimum number of characters required.
For example:
if(mb_strlen($postcomment) > MINIMO_DE_CARACTERES && !isset($uploaded)){
$passa = true;
}
To know if it begins with http
you can use REGEX, just remember that Urls can, start with the http
as to https
, so you can use:
/^(http|https):\/\//
Soon:
if(preg_match('/^(http|https):\/\//', $uploaded) && !isset($postcomment)){
$passa = true;
}
You do not say what should occur if both are filled, this is a situation that should be dealt with, anyway this would be a solution:
if((!empty($postcomment) ^ !empty($uploaded))
&& (mb_strlen($postcomment) > 20 || preg_match('/^(http|https):\/\//', $uploaded))){
$passa = true;
}
Test it out here.
The use of xor
(^
) will cause only if the $uploaded
or the $postcomment
are completed, but not both, in which case if both are completed "will not continue".