Comment Bloquerl'envoi (POST) et afficher une erreur si un mot interdit est détecté ?
Je recherche une manière plus simple, comme avec un array, de bloquer la validation et afficher une erreur si un mot interdit est détecté dans ma variable $_POST['annonce']
J'avais réussi avec un preg_match, à empêcher certains domaine d'email :
Code:
1 2
| if (preg_match("#gmail.com$#", $_POST['ema']) OR preg_match("#yahoo.com$#", $_POST['ema']))
$error['ema'] = 2; |
Mais bon, c'est OK pour 3 ou 4 mots mais pas pour beaucoup plus ...
J'ai testé ça et ça ne marche pas ... après, je ne suis pas très bon en PHP :(
Code:
1 2 3 4
|
$MotsInterdits = array('test','test2','test3');
if (preg_match('$MotsInterdits', $_POST['annonce'])
$error['annonce'] = 1; |
Une aide ?
Merci