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
| <?php
session_start();
try
{
$bdd = new PDO("pgsql:host=localhost;dbname=miah", "postgres", "zohit");
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$id = $_GET['id_projet'];
$_SESSION['id_projet'] = $id;
$reponse = $bdd->prepare("SELECT * FROM projets where id_projet='$id'");
$reponse->execute();
$tab = $reponse->fetch();
?>
<form name="f1" method="POST" action="script/updateprojet.php">
<tr>
<td> Nom : </td> <td> <input name="id_projet" style="width:160px;" type='text' id="name" value="<?php echo $tab['id_projet']; ?>" placeholder="Enter le nom" maxlength="20" class='float'/> </td>
</tr><br></br>
<tr>
<tr>
<td> Nom : </td> <td> <input name="nom_user" style="width:160px;" type='text' id="name" value="<?php echo $tab['nom_user']; ?>" placeholder="Enter le nom" maxlength="20" class='float'/> </td>
</tr><br></br>
<tr>
<td> VILLE : </td> <td><input name="ville" style="width:160px;" type='text' id="name" value="<?php echo $tab['ville']; ?>" placeholder="Enter la ville" maxlength="20" class='float'/> </td>
</tr>
<tr><br></br>
<td> REGION : </td> <td><input name="region_user" style="width:160px;" type='text' id="name" value="<?php echo $tab['region_user']; ?>" placeholder="Enter la region" maxlength="20" class='float'/> </td>
</tr><br></br>
<tr>
<td> ETAT : </td> <td><input name="etat" style="width:160px;" type='text' id="name" value="<?php echo $tab['etat']; ?>" placeholder="Enter l'auteur" maxlength="20" class='float'/> </td>
</tr><br></br>
<tr>
<td> COULEUR : </td> <td><input name="couleur" style="width:160px;" type='text' id="name" value="<?php echo $tab['couleur']; ?>" placeholder="Enter la ville" maxlength="20" class='float'/> </td>
</tr><br></br>
<tr>
<td> </td> <td><input name="submit2" type="submit" class="btn_submit_vert" value="Modifier"/> </td>
</tr>
</form>
et voila l'autre code
<?php
session_start();
try
{
// On se connecte à postgres
$bdd = new PDO("pgsql:host=localhost;dbname=miah", "postgres", "zohit");
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
echo 'Error : ' . $e->getMessage();
die();
}
$id = $_SESSION['id_projet'];
$nom_user = $_POST['nom_user'];
$ville = $_POST['ville'];
$region_user = $_POST['region_user'];
$etat = $_POST['etat'];
$couleur = $_POST['couleur'];
$sth= $bdd->prepare("update projets set nom_user = :nom_user , ville = :ville , region_user = :region_user ,etat = :etat, couleur = :couleur where id_projet = :id ");
$retour = $sth->execute(array(':nom_user'=>$nom_user, ':ville'=>$ville, ':region_user'=>$region_user, ':etat'=>$etat, ':couleur'=>$couleur,':id_projet'=>$id));
if($retour) { echo "<script>
alert('Modification avec succès!! ')
</script>";
}
else {
echo "<script>
alert('Erreur de modification! ')
</script>";
}
//header('location:../clients1.php');
?> |
Partager