I am trying to check whether the answer to the option YES or No on a form. I tried this but it doesn't work:
Here is the error:
Can anyone explain why I'm getting an error or suggest a alternative way of checking for if the answer has been submitted?
PHP:
if preg_match('~^(?:Yes|no)$~i', $rewd]){
$rewd = mysqli_real_escape_string ($dbc, $trimmed['rewd']);
} else{
echo '<p class="error">Please answer Yes or No!</p>';
}
I can't see any mis match with the brackets, so what is causing this error?Parse error: syntax error, unexpected 'preg_match' (T_STRING), expecting '(' in C:\wamp64\www\Test\Form_dat.php on line 69
Can anyone explain why I'm getting an error or suggest a alternative way of checking for if the answer has been submitted?