PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am new to PHP and am trying to validate a mobile phone number in an form I am working on. I have used a validation class that I found but am having trouble adding my own.
How do I say "is not equals to '07' followed by any other numbers"
function DoValidate(&$formars,&$error_hash)
{
if($formars['Mphone']!="07"+"^[0-9]")
{
$error_hash['Mphone']="Please enter a valid mobile number";
return false;
}
return true;
}
I think problem is in this line of code upthere. Your array item is being compared with sum of "07" and any other number given. You might try replace "+" with "."
That will join that two strings into one string while parsing.