modification profil d'un utilisateur
Salut,j'ai in gros problème et je souhaite quelqu'un m'aide ....c'est urgent
j'ai liste utilisateur et voila le page en php qui est nommée :listusers.php
Code:
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
| <html><head>
<title> Liste d'utilisateur</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<center> <h1> Les informations des utilisateurs</h1></center>
<table width='800' align ='center' border='5'>
<tr>
<th>CIN</th>
<th>NOM</th>
<th>Prénom</th>
<th>Etat</th>
<th>Nationalité</th>
<th>Sexe</th>
<th>Naissance</th>
<th>Email</th>
<th>Adresse</th>
<th>Code postale</th>
<th>Login</th>
<th>Password</th>
<th>Supprimer</th>
<th>Modifier</th>
</tr>
<tr>
<?php
mysql_connect('localhost','root','');
mysql_select_db('users');
$query="select * from utilisateur";
$run=mysql_query($query);
while($row=mysql_fetch_array($run))
{
$cin=$row[0];
$nom=$row[1];
$prénom=$row[2];
$etat=$row[3];
$nationalité=$row[4];
$sexe=$row[5];
$naissance=$row[6];
$email=$row[7];
$adresse=$row[8];
$code_postale=$row[9];
$login=$row[10];
$password=$row[11];
?>
<td> <?php echo $cin ;?> </td>
<td> <?php echo $nom ;?> </td>
<td> <?php echo $prénom ;?> </td>
<td> <?php echo $etat ;?> </td>
<td> <?php echo $nationalité ;?> </td>
<td> <?php echo $sexe ;?> </td>
<td> <?php echo $naissance ;?></td>
<td> <?php echo $email ;?> </td>
<td> <?php echo $adresse ;?> </td>
<td> <?php echo $code_postale ;?> </td>
<td> <?php echo $login ;?> </td>
<td> <?php echo $password ;?> </td>
<td> <a href ="supprimer.php?del=<?php echo $cin;?>" > Supprimer</a></td>
<td><a href="modifier.php?cin=<?php echo $cin; ?> "> Modifier </a></td>
</tr>
<?php } ?>
</table>
</body>
</html> |
et voila la page modifier.php
Code:
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
| <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<?php
$cin = $_GET['cin'];
mysql_connect('localhost','root','');
mysql_select_db('users');
$result = mysql_query("SELECT * FROM utilisateur WHERE cin = $cin ");
while($affiche_commentaire = mysql_fetch_array($result))
{
?>
<body>
<h1><center> Modification</center></h1>
<form method="POST" action ="modifier.php?cin=<?php echo $cin;?>" >
<table>
<tr>
<td>Cin*: </td>
<td><input type="text" name="cin" id="cin" value="<?php echo ''.$affiche_commentaire["cin"].'
';?>" required > </td>
</tr>
<tr>
<td>Nom*: </td>
<td><input type="text" name="nom" id="nom" value="<?php echo ''.$affiche_commentaire["nom"].'
';?>" required > </td>
</tr>
<td>Prénom*: </td>
<td><input type="text" name="prénom" id="prénom" value="<?php echo ''.$affiche_commentaire["prénom"].'
';?>" required> </td>
</tr>
<tr>
<td>Etat civil*: </td>
<td><select name="etat" id="etat" value="<?php echo ''.$affiche_commentaire["etat"].'
';?>" >
<option value="Marié">Marié</option>
<option value="Célébataire">Célébataire</option>
<option value="Divorcé">Divorcé</option>
</select></td>
</tr>
<tr><td>Sexe*:</td>
<td> <INPUT TYPE="radio" NAME="Sexe" value="<?php echo ''.$affiche_commentaire["Sexe"].'
';?>" />Masculin</td>
<td><INPUT TYPE="radio" NAME="Sexe" value="<?php echo ''.$affiche_commentaire["Sexe"].'
';?>" checked="yes"/>Féminin</td>
</tr>
<tr>
<td>Nationalité*: </td>
<td><input type="text" name="nationalité" id="nationalité" value="<?php echo ''.$affiche_commentaire["nationalité"].'
';?>" required> </td>
</tr>
<tr>
<td>Date naissance*: </td>
<td><input type="text" name="naissance" id="naissance" value="<?php echo ''.$affiche_commentaire["naissance"].'
';?>" required> </td>
</tr>
<tr>
<td>Email*: </td>
<td><input type="email" name="email" id="email" value="<?php echo ''.$affiche_commentaire["email"].'
';?>" required> </td>
</tr>
<tr>
<td>Adresse*: </td>
<td><input type="text" name="adresse" id="adresse" value="<?php echo ''.$affiche_commentaire["adresse"].'
';?>" required> </td>
</tr>
<tr>
<td>Code postale*: </td>
<td><input type="text" name="postale" id="postale" value="<?php echo ''.$affiche_commentaire["postale"].'
';?>" required> </td>
</tr>
<tr>
<td>Login*: </td>
<td><input type="text" name="login" id="login" value="<?php echo ''.$affiche_commentaire["login"].'
';?>" required> </td>
</tr>
<tr><td> <input type="submit" name="submit" value="modifier" ></td>
<td> <input type="reset" value="Annuler" style="right:30px;" /></td>
</tr>
</form>
</table>
<?php
}
?>
<?php
if(isset($_POST["submit"]))
{
mysql_connect('localhost','root','');
mysql_select_db('users');
$lechamp0 =$_POST["cin"];
$lechamp1 = $_POST["nom"];
$lechamp2 = $_POST["prénom"];
$lechamp3 = $_POST["etat"];
$lechamp4 = $_POST["Sexe"];
$lechamp5 = $_POST["nationalité"];
$lechamp6 = $_POST["naissance"];
$lechamp7 = $_POST["email"];
$lechamp8 = $_POST["adresse"];
$lechamp9 = $_POST["postale"];
$lechamp10 = $_POST["login"];
$result = mysql_query(" UPDATE utilisateur SET
cin='$lechamp0',
nom='$lechamp1',
prénom='$lechamp2',
etat='$lechamp3'
Sexe='$lechamp4',
nationalité='$lechamp5',
naissance='$lechamp6'
email='$lechamp7',
adresse='$lechamp8',
postale='$lechamp9'
login='$lechamp10',
WHERE cin = '$cin'
");
if (!$result)
{
die('Requête invalide : ' . mysql_error());
}
else
{
echo '<p>La modification à été effectué avec succès. <a href=admin.php>Retour à l\'admi
nistration.</a></p>';
}
}
?>
</body>
</html> |
Le problème c'est de modifier les champs de formulaire et être enregistré à la base