I have a very basic HTML form with text boxes defined as
<li id="li_1" >
<label class="description" for="element_1">O teu nome </label>
<span>
<input id="element_1_1" name= "element_1_1" class="element text" pattern="[a-z0-9. -]+" maxlength="255" size="8" value=""/>
<label>Primeiro</label>
</span>
<span>
<input id="element_1_2" name= "element_1_2" class="element text" pattern="[a-z0-9. -]+" maxlength="255" size="14" value=""/>
<label>Apelido</label>
</span>
This input is validated in a php file called email_send_pt.php using
// validation expected data exists
if(!isset($_POST['element_1_1']) ||
!isset($_POST['element_1_2']) ||
!isset($_POST['element_2']) ||{
died('Lamentamos, mas constam erros no seu registo.');
}
$first_name = $_POST['element_1_1']; // required
$second_name = $_POST['element_1_2']; // required
$email = $_POST['element_2']; // required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name) ||
!preg_match($string_exp,$second_name)) {
$error_message .= 'O nome que preencheu não parece ser válido.<br />';
}
I am getting a constant "Compilation failed: range out of order in character class at offset 12 in email_send_pt.php on line 45"
Line 45 is "if(!preg_match($string_exp,$first_name) ||" As input I used "teu" (without "") which should be accepted…
Any idea why this error message is appearing ? Thank you for your help.