Erreur sur déclaration de variable
Bonjour
J'ai un souci des messages d'erreurs sur mes variables que je n'arrive pas à interpréter, pourriez vous me guider svp
Code:
Un des messages d'erreur
Code:
Notice: Undefined index: id in C:\wamp64\www\SDS\UserUpdate_REQUpdate.php on line 22
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
| <?php
//connection au serveur
// connexion à la base de données
$db_username = 'xxx';
$db_password = 'xxx';
$db_name = 'xxxxxxx';
$db_host = 'localhost';
$db = mysqli_connect($db_host, $db_username, $db_password,$db_name)
or die('could not connect to database');
// Création de la connexion
$conn = mysqli_connect($db_host, $db_username, $db_password, $db_name);
// Ctrl de la connexion
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if(isset($_POST['btn_update']))// On regarde si il y a un ajout {
//récupération des valeurs des champs:
{
$id = $_POST["id"] ;
$adresse = $_POST["adresse"] ;
$zip = $_POST["codePostal"] ;
$ville = $_POST["ville"] ;
$tel = $_POST["telephone"] ;
$mail = $_POST["mail"] ;
$statut = $_POST["statut"] ;
$actif = $_POST["actif"] ;
$inactif = $_POST["inactif"] ;
$psw = $_POST["psw"] ;
// Insertion des données
$sql = "UPDATE UTILISATEURS SET UTI_ADRESSE='".$adresse."' ,UTI_ZIP='".$zip."',UTI_VILLE='".$ville."',UTI_PHONE='".$tel."',UTI_MAIL='".$mail."',UTI_STATUT='".$statut."',UTI_ACTIF='".$actif."',UTI_INACTIF='".$inactif."',UTI_PSW='".$psw."' WHERE ID='".$id."'";
if (mysqli_query($conn, $sql)) {
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
mysqli_close($conn);
?> |
Et la page:
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
| <form name="insertion" class="gauche" action="UserUpdate_REQUpdate.php" method="POST">
<div id="Conteneur">
<div class="gauche" >
<table border="0" align="left" cellspacing="2" cellpadding="2"><br>
<!-- style="margin-left:150px;" Correspond à la marge du champ à gauche -->
<label for="id" style="margin-left:150px;">ID :</label>
<input type="text" style="width:300px;" name="id" value="<?php echo $_POST["valeur"];?>"> <br><br>
<label for="nom" style="margin-left:150px;">Nom :</label>
<input type="text" style="width:300px;" name="nom" value="<?php echo $nom?>"> <br><br>
<label for="prenom" style="margin-left:150px;">Prenom :</label>
<input type="text" style="width:300px;" name="prenom" value="<?php echo $prenom?>"><br><br>
<label for="adresse" style="margin-left:150px;">Adresse :</label>
<textarea name="adresse" cols="35" rows="5" id="adresse" value=""><?php echo $adresse?></textarea><br><br>
<label for="codePostal" style="margin-left:150px;">Code Postal :</label>
<input type="text" style="width:300px;" name="codePostal" value="<?php echo $zip?>"><br><br>
<label for="ville" style="margin-left:150px;">Ville :</label>
<input type="text" style="width:300px;" name="ville" value="<?php echo $ville?>"><br><br>
<tr align="left" >
<td colspan="2" >
<input type="submit" style="background:#FF8C00;border: 1px solid #FF8C00;color: #000000;" id='submit' name='btn_update' value='Mise à jour' >
<input type="submit"style="background:#FF0000;border: 1px solid #FF0000;" id='submit' name='btn_delete' value='Supprimer' >
</td></tr>
</table>
</div>
</div>
<!-- Conteneur droit -->
<div class="droite" >
<table border="0" align="right" cellspacing="2" cellpadding="2"><br><br>
<label for="telephone" style="margin-left:300px;">Téléphone protable :</label>
<input type="text" style="width:300px;" name="telephone" value="<?php echo $phone?>"><br><br>
<label for="mail" style="margin-left:300px;">Courriel :</label>
<input type="text" style="width:300px;" name="mail" value="<?php echo $mail?>"><br><br>
<label for="indate" style="margin-left:300px;">Date d'entrée :</label>
<input type="date" style="width:300px;" name="indate" value="<?php echo $create?>"><br><br>
<label for="statut" style="margin-left:300px;">Statut :</label>
<select id="statut" name="statut" style="width:300px;">
<option value="Administrateur">Administrateur</option>
<option value="Direction">Direction</option>
<option value="Manager">Manager</option>
<option value="Technicien">Technicien</option>
<option value="Logistique">Logistique</option>
<option value="Administration">Administration</option>
<option value="valeur7" selected></option>
</select><br /><br/><br><br>
<label for="profil" style="margin-left:300px;">Profil :</label>
<input type="radio" id="actif" name="actif" checked="checked">
<label for="actif" >Actif</label>
<input type="radio" id="inactif" name="actif">
<label for="inactif">Inactif</label><br/><br>
<label for="psw" style="margin-left:300px;">Mot de passe :</label>
<input type="text" style="width:300px;" name="psw" value="<?php echo $psw?>"><br>
</table>
</div>
</form>
<!-- Mise à jour de la BDD -->
<?php
require 'UserUpdate_REQUpdate.php'
?> |