I am trying to find out if the user has entered any inappropriate words in my registration form. I thought I would use the strpos function but not sure if the code is correct or not?
I tried using the strpos function and supplied 3 variables called $first, $find, $offset to find any inappropriate words in the $find variables for the variable $first
$offset = 0;
$find = array('retard', 'stupid', 'rascist', 'bastard', 'fuck', 'fuck-off');
if (strpos($first, $find, $offset)) {
header("Location: ../signup.php?signup2=rudewords");
exit();
But I guess the error here is that I do not know how to use the array with the strpos
Updated code:
if (array_sum(array_map(function ($i) use ($first, $last, $email, $uid, $password) {
return strpos($first, $last, $email, $uid, $password, $i) !== FALSE;
}, $find)) > 0) {
header("Location: ../signup.php?signup2=badwords");
exit();