Why not run a regular expression?

// Check for correct name
if (empty($_POST["first_name"])) {
 $errName = "Name is definitely<br>";
} else {
 $first_name = $_POST['first_name'];
 if (!preg_match("/^[a-za-Aeea-zA-Z]+$/m", $first_name)) {
 $errName = "In name only letters allowed<br>";
 $first_name = ";
}
}


After executing still displays $errName, though, the algorithm I wrote is correct (maybe): if there are no matches in this variable that is assigned the error text into a variable
March 23rd 20 at 19:01
1 answer
March 23rd 20 at 19:03
Compare the encoding in which the file is stored with this program code, and the encoding in which part of the page/come data $_POST. They should be the same.

Find more questions by tags PHP