Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 31/05/2011, 14h59   #1
Invité de passage
 
Inscription : mai 2011
Messages : 7
Détails du profil
Informations forums :
Inscription : mai 2011
Messages : 7
Points : 2
Points : 2
Par défaut Erreur de modification sql.

Bonjour ! Je voudrais modifier les informations d'une base a partir d'un formulaire mais Wamp m'affiche cette erreur :
"Notice: Undefined index"

Voici mon code :
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
<?php
	  //Connexion
				include ('info_connexion_bdd.php');
				$mysql_link=mysql_connect(SERVEURBDD,UTILISATEUR,MOTPASSE) or die('ERREUR connexion');
				mysql_select_db(NOMBDD) or die ('ERREUR base de données');
 
				$client=$_GET['id'];
				$Information_client = mysql_query ('select * from t_client where num_client='.$client.'');
				$info_client= mysql_fetch_assoc($Information_client);
	  ?>
		<form method="post" name="frmAjout" id="frmAjout"  onsubmit="return verif_formulaire();">
			<h2>Modifier les informations du client N°<?php echo $client; ?> :</h2>
					<fieldset>
						<label for="txtType" class="gras"> Type : </label>
						<input type="checkbox" id="txtType" name="txtType" value="Particulier">Particulier
						<input type="checkbox" id="txtType" name="txtType" value="Professionnel">Professionnel
						<br /><br />
						<label for="txtNom" class="gras"> Nom* : </label>
						<input type="text" id="txtNom" name="txtNom" size="20"            onchange="javascript:this.value=this.value.toUpperCase();" value="<?php echo $info_client["nom_client"] ?>"/>
                                               <button><a href="liste_clients.php"> Annuler</button>
						<button type="submit"><a href="update.php?id=<?php echo $info_client["num_client"] ?>"> Modifier</button>
					</fieldset>
	  	</form>
		<?php
		mysql_close ($mysql_link);
		?>
Voici mon fichier update.php :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
				//Connexion
				include ('info_connexion_bdd.php');
				$mysql_link=mysql_connect(SERVEURBDD,UTILISATEUR,MOTPASSE) or die('ERREUR connexion');
				mysql_select_db(NOMBDD) or die ('ERREUR base de données');
 
				//Modification
				if (isset($_POST['id'], $_POST['txtType'], $_POST['txtNom']))
				{
				$client=$_POST['id'];
				$Type=$_POST['txtType'];
				$Nom=$_POST['txtNom'];
 
				mysql_query('update t_client set num_client=\''.$client.'\',type_client=\''.$Type.'\', nom_client=\''.$Nom.'\' where num_client='.$client.'')or die (mysql_error());
				}
 
 
				//Déconnexion
				mysql_close ($mysql_link);
?>
Merci a tous ceux qui essaye de m'aider.
hacker64 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 15h18   #2
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 270
Points : 7 270
Bonsoir,

à quelle ligne est indiqué cet erreur et tu peux nous donner plus de message d'erreur.
Sinon
Citation:
$client=$_GET['id'];
l'id est dans l'Url ?

EDIT:
Citation:
$client=$_POST['id'];
Il n'y a pas d'élément avec le name id dans ton formulaire.

A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 31/05/2011, 16h08   #3
Invité de passage
 
Inscription : mai 2011
Messages : 7
Détails du profil
Informations forums :
Inscription : mai 2011
Messages : 7
Points : 2
Points : 2
Les erreurs sont ligne 11 et 12, mes variable $Nom et $Type ne reçoivent rien. Et l'id est effectivement dans l'url.
hacker64 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 16h18   #4
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 270
Points : 7 270
Citation:
<button><a href="liste_clients.php"> Annuler</button>
<button type="submit"><a href="update.php?id=<?php echo $info_client["num_client"] ?>"> Modifier</button>
Code :
1
2
<input type="hidden" name="id" value="<?php echo $info_client["num_client"] ?>" />
<input type="submit" value="Modifier"/>
et ajoute un attribut action="update.php" dans ton form.

A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 16h23   #5
Invité de passage
 
Inscription : mai 2011
Messages : 7
Détails du profil
Informations forums :
Inscription : mai 2011
Messages : 7
Points : 2
Points : 2
C'était une partie du problème oui ! Merci
hacker64 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h42.


 
 
 
 
Partenaires

Hébergement Web