I hope someone can help!!!
In coding a form validation, I got the error message "Deprecated: Function ereg() is deprecated in E:\Zacel_Development\sa_model_watch.co.za\insert_newProf.php on line 184"
I did some research and found out I need to change !eregi and !ereg to preg_match...
I did try this, but to no avail... can anyone please check my code and advise as I am stumped!
My Code Snippet:
/* Check is numeric*/
$regex = "[0-9]{10}";
if(!ereg($regex,$field)){
$form->setError($fieldValue, "* Contact number invalid");
}
SHOULD APPARENTLY BE:
/* Check is numeric*/
$regex = "[0-9]{10}";
if(!preg_match($regex,$field)){
$form->setError($fieldValue, "* Contact number invalid");
}
AND:
/* Check if valid email address */
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
."\.([a-z]{2,}){1}$";
if(!eregi($regex,$field)){
$form->setError($fieldValue, "* Email invalid");
}
SHOULD APPARENTLY BE:
/* Check if valid email address */
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
."\.([a-z]{2,}){1}$";
if(!preg_match($regex,$field)){
$form->setError($fieldValue, "* Email invalid");
}
This still doesn't work... What am I doing wrong?