<?php $erreur = false; if ($action == "validation") { $nom = $_POST["nom"]; $prenom = $_POST["prenom"]; $email = $_POST["email"]; if (!preg_match("/[A-Za-z]{2,30}/", $nom)) { $erreur = true; } if (!$erreur and !preg_match("/[A-Za-z]{2,30}/", $prenom)) { $erreur = true; } // ... if ($erreur) { $smarty->display("{$page}.tpl"); } else { $client = new Client(); $client->setNom($nom); $client->setPrenom($prenom); $client->setEmail($email); $client->save(); $smarty->display("CompteClient.tpl"); } } else { $smarty->display("{$page}.tpl"); }