I have been given an assignment where I need to check if a Booking Reference is valid. The Booking Reference has to be in the style of "ABC-1234". I need to use PHP to check the first three letters are either "ACT ABQ BDE". This is then followed by the "-". Then I need to check the numbers are in the following sequence, the first digit is either "1" or "2", and the following three digits are in the 0-9 range. This is the code I currently have to check this:
if (isset($webdata['bookingreference'] )) {
if (!preg_match("/^ [ACT] [ABQ] [BDE] - [(1),(2)]{5}[0-9]{6,}$/", $webdata['bookingreference'])) {
$formerror['bookingreference'] = '<span class="warn" >Not valid on server: Invalid booking reference</span>';
$valid = FALSE;
}
However, when I test this, I always get the message it is valid no matter what the sequence is.