function addmail($nom, $fnom, $lnom, $tel, $mail, $service) { // $arrayVariable["column name"] = formatted SQL value global $db; $mdp = ChaineAleatoire(8); $values["pseudo"] = MySQL::SQLValue($nom); $values["mail"] = MySQL::SQLValue($mail); $values["tel"] = MySQL::SQLValue($tel); $values["fonction"] = MySQL::SQLValue($service); $values["nom"] = MySQL::SQLValue($fnom); $values["prenom"] = MySQL::SQLValue($lnom); $values["mdp"] = MySQL::SQLValue($mdp); // Execute the insert $result = $db->InsertRow("mail", $values); // If we have an error if (createmail($nom, $mdp)) { if (!$result) { $db->Kill($result); return false; } else { // createmail($nom,$mdp); sendmail($fnom, $mail, $nom, $mdp, $lnom); return true; } } else { return false; } }
if (tp('verif') == 1) { if (tp('captcha') != $_SESSION['Captcha']) { $messageok = 0; } else { model::load('page', 'contact'); if (!addmail(tp('name'), tp('email'), tp('to'), tp('sujet'), tp('message'), tp('ip'))) { $messageok = 1; } else { //session_start(); function ChaineAleatoire($nbcar) { $chaine = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; srand((double) microtime() * 1000000); $variable = ''; for ($i = 0; $i < $nbcar; $i++) { $variable .= $chaine[rand() % strlen($chaine)]; } return $variable; } if (isset($_SESSION['Captcha'])) { unset($_SESSION['Captcha']); } $_SESSION['Captcha'] = ChaineAleatoire(5); $messageok = 2; } } define('MAILSTAT', $messageok); view::load('page', 'contact'); } else { view::load('page', 'contact'); }