1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?php>
/* Connexion à une base MySQL avec l'invocation de pilote */
$dsn = 'mysql:dbname=vip_pro_crm;host=127.0.0.1';
$user = 'root';
$password = '';
try {
$bdd = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
echo 'Connexion échouée : ' . $e->getMessage();
}
?>
<?php>
session_start();
if(isset($_POST['valeur'])) {
$nom = htmlspecialchars(trim($_POST['nom']);
$a = htmlspecialchars(trim($_POST['adresse']);
$v = htmlspecialchars(trim($_POST['ville']);
$cp = htmlspecialchars(trim($_POST['code_postal']);
$email = htmlspecialchars(trim($_POST['email']);
$tf = htmlspecialchars(trim($_POST['telephonefixe']);
$tf2 = htmlspecialchars(trim($_POST['telephonefixe_2']);
$tp =htmlspecialchars(trim($_POST['telephoneport']);
$tp2 = htmlspecialchars(trim($_POST['telephoneport_2']);
$nc = htmlspecialchars(trim($_POST['nomcontact']);
$nc2 = htmlspecialchars(trim($_POST['nomcontact_2']);
$client = htmlspecialchars(trim($_POST['client']);
if(!empty($_POST['client']) AND !empty($_POST['nom']) AND !empty($_POST['adresse']) AND !empty($_POST['ville']) AND !empty($_POST['code_postal']) AND !empty($_POST['email']) AND !empty($_POST['telephonefixe']) AND !empty($_POST['telephonefixe_2']) AND !empty($_POST['telephoneport']) AND !empty($_POST['telephoneport_2']) AND !empty($_POST['nomcontact']) AND !empty($_POST['nomcontact_2'])) {
$insertmbr = $bdd->prepare("INSERT INTO fiche_client(nom, adresse, ville, code_postal, email, telephonefixe, telephonefixe_2, telephoneport, telephoneport_2, nomcontact, nomcontact_2) VALUES(:n, :a, :v, :cp, :email, :tf, :tf2, :tp, :tp2, :nc, :nc2)");
$insertmbr->execute(array(":n"=>$nom,":a"=>$a,":v"=>$v,":cp"=>$cp,":email"=>$email,":tf"=>$tf,":tf2"=>$tf2,":tp"=>$tp,":tp2"=>$tp2,":nc"=>$nc,":nc2"=>$nc2));
var_dump($insertmbr->errorInfo());
$erreur = "Votre fiche client a bien été créé !";
if($insertmbr)
{
echo 'Data Inserted';
}else{
echo 'Data Not Inserted';
}
}
}
?> |
Partager