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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| if (!isset($_SESSION['login']))
{
header ('Location: index.php');
exit();
}
?>
<?php
$id = $_GET['id'];
require_once "./includes/config.php";
require_once "./includes/head.php";
?>
</head>
<body>
<?php
if (isset($_POST['modification']) && $_POST['modification'] == 'Modification') {
// on teste l'existence de nos variables. On teste également si elles ne sont pas vides
if ((isset($_POST['nom']) && !empty($_POST['nom'])) && (isset($_POST['prenom']) && !empty($_POST['prenom'])) && (isset($_POST['adresse']) && !empty($_POST['adresse']))
&& (isset($_POST['tel1']) && !empty($_POST['tel1'])) && (isset($_POST['tel2']) && !empty($_POST['tel2']))
&& (isset($_POST['tel3']) && !empty($_POST['tel3'])) && (isset($_POST['mail']) && !empty($_POST['mail'])) && (isset($_POST['daten']) && !empty($_POST['daten']))) {
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['mail'])) {
$erreur = 'l\'adresse mail fournie n\'est pas valide.';
}
$sql ="UPDATE'client' SET
'nom' = '".mysqli_real_escape_string($connexion, $_POST['nom'])."',
'prenom' = '".mysqli_real_escape_string($connexion, $_POST['prenom'])."',
'adresse' = '".mysqli_real_escape_string($connexion, $_POST['adresse'])."',
'cp_id' = '".mysqli_real_escape_string($connexion, $_POST['id_cp'])."',
'tel_port' = '".mysqli_real_escape_string($connexion, $_POST['tel1'])."',
'tel1' = '".mysqli_real_escape_string($connexion, $_POST['tel2'])."',
'autre_tel' = '".mysqli_real_escape_string($connexion, $_POST['tel3'])."',
'datenaissance' = '".mysqli_real_escape_string($connexion, $_POST['daten'])."',
'genre' = '".mysqli_real_escape_string($connexion, $_POST['genre'])."',
'email' = '".mysqli_real_escape_string($connexion, $_POST['mail'])."'
WHERE 'id' = '$id'";
mysqli_query($connexion, $sql) or die('Erreur SQL !'.$sql.'<br />'.mysqli_error($connexion));
mysqli_close($connexion);
header ('Location: clients.php');
}
else {
$erreur = 'Au moins un des champs est vide.';
}
}
?>
<?php
$sql = 'SELECT id, nom, prenom, adresse, id_cp, cp, ville, tel1, tel_port, autre_tel, email, datenaissance, genre from client
LEFT OUTER JOIN cp_autocomplete ON client.cp_id = cp_autocomplete.id_cp WHERE id="'.$_GET['id'].'"' ;
$resultat =mysqli_query($connexion,$sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysqli_error());
$client=mysqli_fetch_array($resultat);
mysqli_close($connexion);
?>
<form action="modifclient.php?id=<?php echo $id;?>" class="register" method="post">
<fieldset class="row1">
<legend>Client : <?php echo $client['nom'].' '. $client['prenom']; ?></legend>
<label>Titre : * </label>
<select class="date" name="genre" value="<?php echo $client['genre']; ?>">
<option value="1">Mr</option>
<option value="2">Mme</option>
<option value="3">Mlle</option>
<option value="4">Mr & Mme</option>
<option value="5">Dr</option>
<option value="6">Maitr</option>
</select>
</p>
<p>
<label for="nom">Nom client : *</label><input class="long" type="text" name="nom" value="<?php echo $client['nom']; ?>"/>
<label for="prenom">Prènom : *</label><input class="long" type="text" name="prenom" value="<?php echo $client['prenom']; ?>"/>
</p>
<p>
<label for="adresse">Adresse : *</label><input class="long" type="text" name="adresse" value="<?php echo $client['adresse']; ?>"/>
<input id="id_cp" type="hidden" name="id_cp" value="<?php echo $client['id_cp']; ?>" />
<label for="cp">Code postal : *</label><input id="cp" type="text" name="cp" value="<?php echo $client['cp']; ?>"/>
</p>
<p>
<label for="ville">Ville : *</label><input id="ville" class="long" type="text" name="ville" value="<?php echo $client['ville']; ?>"/>
<label for="tel1">Téléphone : *</label><input class="long" type="tel" name="tel1" value="<?php echo $client['tel1']; ?>"/>
</p>
<p>
<label for="tel2">Portable : *</label><input class="long" type="tel" name="tel2" value="<?php echo $client['tel_port']; ?>"/>
<label for="tel3">Autres tel : *</label><input class="long" type="tel" name="tel3" value="<?php echo $client['autre_tel']; ?>"/>
</p>
<p>
<label for="mail">Email : *</label><input class="long" type="text" name="mail" value="<?php echo $client['email']; ?>"/>
<label for="daten">Date de naissance : *</label><input class="long" type="date" name="daten" value="<?php echo $client['datenaissance']; ?>"/>
</p>
<input class="button" type="submit" name="modification" value="Modification">
<input class="button" value="Retour Gestion" OnClick="window.location.href='client.php'">
</form>
</body>
</html> |
Partager