<?php

  include ('../../composants/connect-bdd/connexion_bdd.php');

  $id = $_GET['id'];
  $id_contact = $_POST['id_contact'];

  $societe    = $_POST['societe'];
  $nom        = $_POST['nom'];
  $prenom     = $_POST['prenom'];
  $email      = $_POST['email'];
  $tel        = $_POST['tel'];

  $cathegorie = $_POST['groupe'];

  $abonnee    = $_POST['abonnee'];

  $req = $bdd->prepare(" UPDATE contact SET nom=:nom, prenom=:prenom, societe=:societe, email=:email, tel=:tel, cathegorie=:cathegorie, abonnee=:abonnee WHERE id=$id_contact");
  $req->execute(array(
      'nom' => $nom,
      'prenom' => $prenom,
      'societe' => $societe,
      'email' => $email,
      'tel' => $tel,
      'cathegorie' => $cathegorie,
      'abonnee' => $abonnee
  ));
  if($req != null){
    header ("Location: $_SERVER[HTTP_REFERER]" );
  }
  else{
    echo("<script>alert('ERROR dupdate');</script>");
  }
?>
