Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD
PHP & SGBD Forum d'entraide sur les SGBD avec PHP. Avant de poster : FAQ BDD, toutes les FAQ PHP, cours BDD et sources BDD
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 19/08/2007, 04h02   #1
Invité de passage
 
Inscription : août 2007
Messages : 25
Détails du profil
Informations forums :
Inscription : août 2007
Messages : 25
Points : 4
Points : 4
Par défaut [SQL] récupération et modification données formulaire

Bonjour ,
C'est mon deuxieme message sur ce forum et suite a la résolution d'un de mes anciens problems sur ce forum , je refait donc appel a vous .
Voici mon problem :

J'essai de créé un espece de profil je mexplique des personnes entrent plusieurs informations dans un formulaire et les sauvegardent dans la base de données pour ensuite les resortir dans un endroit voulu mais aussi dans le formulaire de modification de profil ( Pour plus de comprehension : dans un input texte je met value="<?php echo $variable; ?>" ) .

Tout d'abord lors de l'inscription je remplace tout les champs du profil ( qui ne sont pas demander lors de l'inscription ) par des n/a , piur n'avoir juste qu'une seul requette sql qui permettrai de les modifier , mais la modification ne s'effectue pas donc je fait appel a vous .
Je vous met si dessous :
- la page myprofil.php ( la ou l'on modifie les données du profil )
- la page myprofil_verif.php ( la ou l'on verifie les données )

myprofil.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
 
<?php
if (isset($_SESSION['connect']) && $_SESSION['connect'] == "1")
{
$pseudo = $_SESSION['pseudo'] ;
$query = "SELECT id FROM `membres` WHERE `pseudo`='$pseudo'" ;
$resultat = mysql_query($query) or die(mysql_error()); 
$donnes = mysql_fetch_array($resultat);
$user_id = $donnes['id'] ;
$query = "SELECT * FROM `membres_pref` WHERE `id_user`='$user_id'" ;
$resultat = mysql_query($query) or die(mysql_error()); 
$donnees = mysql_fetch_array($resultat);
$prenom = $donnees['prenom'];
$team = $donnees['team'];
$casque = $donnees['casque'];
$origine = $donnees['origine'];
$location = $donnees['location'];
$age = $donnees['age'];
$sexe = $donnees['sexe'];
$sport = $donnees['sport'];
$website = $donnees['website'];
$msn = $donnees['msn'];
$souris = $donnees['souris'];
$tapis_souris = $donnees['tapis_souris'];
$ecran = $donnees['ecran'];
$cpu = $donnees['cpu'];
$cg = $donnees['cg'];
$sorte_connect = $donnees['sorte_connect'];
$clavier = $donnees['clavier'];
$boisson = $donnees['boisson'];
$nouriture = $donnees['nouriture'];
$film = $donnees['film'];
$acteur = $donnees['acteur'];
$serie = $donnees['serie'];
$musique = $donnees['musique'];
$livre = $donnees['livre'];
$personne = $donnees['personne'];
$joueur = $donnees['joueur'];
$aim_fx = $donnees['aim_fx'];
$voiture = $donnees['voiture'];
$sorte_connect = $donnees['sorte_connect'];
$game = $donnees['game'];
?>
<br>
<form method="post" action="modules/User/myprofil_verif.php">
<table bgcolor="black" align="center" border="0" cellspacing="0" cellpadding="0">
<td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0">
<tr><td height="16" bgcolor="black"><span class="myprofil">You</span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Prenom : <input name="prenom" type="text" value="<?php echo $prenom; ?>" /></input></span> 
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Team : <input name="team" type="text" value="<?php echo $team; ?>" /></input></span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Origine : <input name="origine" type="text" value="<?php echo $origine; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Location : <input name="location" type="text" value="<?php echo $location; ?>" /></input></span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Age : <input name="age" type="text" value="<?php echo $age; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Sexe :  <input name="sexe" type="text" value="<?php echo $sexe; ?>" /></input></span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Web site : <input name="website" type="text" value="<?php echo $website; ?>" /></input></span>	
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">MSN :  <input name="msn" type="text" value="<?php echo $msn; ?>" /></input></span>
<tr>
</table>
</td>
<td width="294" valign="top">
<table width="294" align="left" border="0" cellspacing="0" cellpadding="0">
<tr><td height="16" bgcolor="black"><span class="myprofil">Hardware : </span>
<tr><td height="16" background="images/bg01_last_wars.jpg"><span class="myprofil">Souris : <input name="souris" type="text" value="<?php echo $souris; ?>"></input></span>
 
<tr><td height="16" background="images/bg02_last_wars.jpg"><span class="myprofil">Tapis de souris: <input name="tapis_souris" type="text" value="<?php echo $tapis_souris; ?>" /></input></span>	   	
<tr><td height="16" background="images/bg01_last_wars.jpg"><span class="myprofil">Micro/Casque : <input name="casque" type="text" value="<?php echo $casque; ?>" /></input></span>
<tr><td height="16" background="images/bg02_last_wars.jpg"><span class="myprofil">Ecran : <input name="ecran" type="text" value="<?php echo $ecran; ?>" /></input></span> 
<tr><td height="16" background="images/bg01_last_wars.jpg"><span class="myprofil">CPU : <input name="cpu" type="text" value="<?php echo $cpu; ?>" /></input></span> 
<tr><td height="16" background="images/bg02_last_wars.jpg"><span class="myprofil">Carte graphique : <input name="cg" type="text" value="<?php echo $cg; ?>" /></input></span>
<tr><td height="16" background="images/bg01_last_wars.jpg"><span class="myprofil">Connection : <input name="sorte_connect" type="text" value="<?php echo $sorte_connect; ?>" /></input></span>
<tr><td height="16" background="images/bg02_last_wars.jpg"><span class="myprofil">Clavier : <input name="clavier" type="text" value="<?php echo $clavier; ?>" /></input></span>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0">
<tr><td height="16" bgcolor="black"><span class="myprofil">Favorites : </span>
 
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Boisson: <input name="boisson" type="text" value="<?php echo $boisson; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Nouriture :  <input name="nouriture" type="text" value="<?php echo $nouriture; ?>" /></input></span>	
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Film: <input name="film" type="text" value="<?php echo $film; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">acteur: <input name="acteur" type="text" value="<?php echo $acteur; ?>" /></input></span> 
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">TV Series: <input name="serie" type="text" value="<?php echo $serie; ?>" /></input></span>	
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Musique: <input name="musique" type="text" value="<?php echo $musique; ?>" /></input></span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Livre: <input name="livre" type="text" value="<?php echo $livre; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Personne : <input name="personne" type="text" value="<?php echo $personne; ?>" /></input></span>
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Joueur : <input name="joueur" type="text" value="<?php echo $joueur; ?>" /></input></span>
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Aim.fx : <input name="aim_fx" type="text" value="<?php echo $aim_fx; ?>" /></input></span>	
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Voiture : <input name="voiture" type="text" value="<?php echo $voiture; ?>" /></input></span>	
<tr><td height="16" background="images/bg01_right.jpg"><span class="myprofil">Sport : <input name="sport" type="text" value="<?php echo $sport; ?>" /></input></span> 	
<tr><td height="16" background="images/bg02_right.jpg"><span class="myprofil">Game : <input name="game" type="text" value="<?php echo $game; ?>" /></input></span>	
<tr><td>-----</tr></td>
</table>
<td width="294" valign="top">
<table width="294" align="left" border="0" cellspacing="0" cellpadding="0">
<tr><td height="16" bgcolor="black"><span class="myprofil">Avatard : </span>
<tr><td valign="top" rowspan "14"><span class="asterisque ">( Attention le module de gestion de l'avatard n'est pas actif ) </span><br>
<td> </table>
<br><br>
	<input type="submit" value="ok" />
	</form>
  </table>
  <?php
  }
  ?>

myprofil_verif.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
 
<?php
session_start();
include('../../config.php');
if (isset($_SESSION['connect']) && $_SESSION['connect'] == "1")
{
$pseudo = $_SESSION['pseudo'];
$prenom = $_POST['prenom'];
$team = $_POST['team'];
$origine = $_POST['origine'];
$location = $_POST['location'];
$age = $_POST['age'];
$sexe = $_POST['sexe'];
$website = $_POST['website'];
$msn = $_POST['msn'];
$souris = $_POST['souris'];
$tapis_souris = $_POST['tapis_souris'];
$casque = $_POST['casque'];
$ecran = $_POST['ecran'];
$cpu = $_POST['cpu'];
$cg = $_POST['cg'];
$sorte_connect = $_POST['sorte_connect'];
$clavier = $_POST['clavier'];
$boisson = $_POST['boisson'];
$nouriture = $_POST['nouriture'];
$film = $_POST['film'];
$acteur = $_POST['acteur'];
$serie = $_POST['serie'];
$musique = $_POST['musique'];
$livre = $_POST['livre'];
$personne = $_POST['personne'];
$joueur = $_POST['joueur'];
$aim_fx = $_POST['aim_fx'];
$voiture = $_POST['voiture'];
$sport = $_POST['sport'];
$game = $_POST['game'];
$query = "SELECT * FROM `membres` WHERE `pseudo` = '$pseudo'";
$resultat = mysql_query($query) or die(mysql_error()); 
$donnees = mysql_fetch_array($resultat);
$id_user = $donnees['id'] ;
mysql_query("UPDATE `membres_pref` SET `prenom`='$prenom', `team`='$team', `origine`='$origine', `location`='$location', `age`='$age', `sexe`='$sexe', `website`='$website', `msn`='$msn', `souris`='$souris', `tapis_souris`='$tapis_souris', `casque`='$casque', `ecran`='$ecran', `cpu`='$cpu', `cg`='$cg', `sorte_connect`='$sorte_connect', `clavier`='$clavier', `boisson`='$boisson', `nouriture`='$nouriture', `film`='$film', `acteur`='$acteur', `serie`='$serie', `musique`='$musique', `livre`='$livre', `personne`='$personne', `joueur`='$joueur', `aim_fx`='$aim_fx', `voiture`='$voiture', `sport`='$sport', `game`='$game' WHERE `id`='$id_user'");
echo ' <SCRIPT LANGUAGE="JavaScript">
alert("Preferences mit a jour")
document.location.href="../../index.php" </SCRIPT>';
}
?>
Ce que j'ai deja essayer :

- Rajouter une ligne de if(isset($_POST['variable'] pour verifier chaque variable mais tous les $_POST sont bon et existe

Mais apres sa je ne voit pas d'où cela peut venir ...
Voila merçi de vos futurs reponses et d'avoir pris de votre temp pour lire mon post , pour votre imformation personnel et pour rediger vos message je debute dans le domaine du " PHP " , donc si vous pourriez detaillez un peu vos reponses sa serait vraiment gentil

---------------------------------------------------
nitteN : Apprentit
---------------------------------------------------
nitteN est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/08/2007, 05h16   #2
Membre régulier
 
Avatar de B.Moncef
 
Étudiant
Inscription : août 2007
Messages : 75
Détails du profil
Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : août 2007
Messages : 75
Points : 83
Points : 83
Rajoute un or die(mysql_error()) après ta requête update et re-copie l'erreur qui apparaît ici.

Par contre ton script est très pénible a lire. Il est aussi pas du tout sécurisé et pourrais être grandement optimisé. Essai de l'améliorer.

Surtout niveau sécurité la c'est vraiment la porte ouverte aux injections sql. utilises mysql_real_escape_string() sur les données que tu récupères et que tu dois utiliser dans une requête sql.
B.Moncef est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/08/2007, 12h14   #3
Invité de passage
 
Inscription : août 2007
Messages : 25
Détails du profil
Informations forums :
Inscription : août 2007
Messages : 25
Points : 4
Points : 4
merçi beaucoup , avec l'aide de or die(mysql_error()) j'ai trouver que l'erreur vener du nom que j'avait donné a l'id qui n'tait pas `id` mais `user_id` Merçi je place le post en résolu
nitteN 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 09h00.


 
 
 
 
Partenaires

Hébergement Web