I’m trying to check some user input using preg_match and it’s working just fine with XAMPP but when I upload it on my website the code suddenly doesn’t work?
Here’s the code:
if (empty($firstName) || empty($lastName)) {
header("Location: ../index.php?error=emptyFields&firstName=".$firstName."&lastName=".$lastName);
exit();
} else if (!preg_match("/^[a-zA-Z\s-åäöÅÄÖ]*$/", $firstName) || !preg_match("/^[a-zA-Z\s-åäöÅÄÖ]*$/", $lastName)) {
header("Location: ../index.php?error=invalidChars");
exit();
} else { (code continues)
The first part (checking for empty fields) works just fine but the else if statement always gets run on infinityFree for some reason. I’m just trying to check if the user has input characters that shouldn’t belong in a name and I don’t understand why uploading it on my website breaks the check.