Problème script profil en PHP / MYSQL

Résolu
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention   -  
 Utilisateur anonyme -
Bonsoir,
Voila mon problème j'essaye de mettre en place un script pour que les membres ont un accès à leur profil mais le problème c'est qu'il m'affiche les informations d'un autre membre.

Par exemple je me connecte avec le login Azerty123 et quand je vais sur mon profil je vois bienvenue Azerty123 mais en dessous je vois un autre pseudo et des informations d'une autre personne

Voici le script:

<div align="center" class="titre"><?php echo 'Bienvenue dans la zone membre ' . $_SESSION['login'] . ''; ?></div><br>
<?php //Affichage base solo
$i = "0";
//Selection de la table
	$query = "SELECT * from membre";
	$result = MYSQL_QUERY($query);
   $result = mysql_query("SELECT * FROM membre");
   $total= mysql_fetch_array($result);  
       
  	    $t_id = mysql_result($result, $i, "id");
		$t_login = mysql_result($result, $i, "login");
		$t_mail = mysql_result($result, $i, "mail");
		$t_tel = mysql_result($result, $i, "tel");
		$t_date = mysql_result($result, $i, "date");
		$t_ip = mysql_result($result, $i, "ip");
	                               
  ?>
	<table width="300" border="2" align="center" cellpadding="3" cellspacing="2">
  <tr>
    <td>	
	<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><div align="center" class="aff2"><?php echo "$t_login"; ?></div></td>
    </tr>
  <tr>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Mail : </span><span class="aff2"><?php echo "$t_mail"; ?></span></div></td>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Tel: </span><span class="aff2"><?php echo "$t_tel"; ?></span></div></td>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Date: </span><span class="aff2"><?php echo "$t_date"; ?></span></div></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center"><span class="nom">IP : </span><span class="aff2"><?php echo "$t_ip"; ?></span></div></td>
    </tr> 
	  </table>
    </td>
  </tr>
</table>


Voici merci d'avance !
A voir également:

4 réponses

Utilisateur anonyme
 
<div align="center" class="titre"><?php echo 'Bienvenue dans la zone membre '.$_SESSION['login'].''; ?></div><br>
<?php
$result = mysql_query('SELECT * FROM membre WHERE login="'.$_SESSION['login'].'"');
$total = mysql_fetch_assoc($result);        
?>
<table width="300" border="2" align="center" cellpadding="3" cellspacing="2">
 <tr>
  <td> 
   <table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
     <td colspan="2"><div align="center" class="aff2"><?php echo $total['login']; ?></div></td>
    </tr>
    
    <tr></tr>
    
    <tr>
     <td><div align="center"><span class="nom">Mail : </span><span class="aff2"><?php echo $total['mail']; ?></span></div></td>
    </tr>
    
    <tr>
     <td><div align="center"><span class="nom">Tel: </span><span class="aff2"><?php echo $total['tel']; ?></span></div></td>
    </tr>
    
    <tr>
     <td><div align="center"><span class="nom">Date: </span><span class="aff2"><?php echo $total['date']; ?></span></div></td>
    </tr>
    
    <tr>
     <td colspan="2"><div align="center"><span class="nom">IP : </span><span class="aff2"><?php echo $total['ip']; ?></span></div></td>
    </tr> 
   </table>
  </td>
 </tr>
</table>
1
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
Heu merci ca fonctionne !
0
Utilisateur anonyme
 
Pas de soucis. Met un "+1" au cas ou qu'une personne à un problème du même genre qu'il ai la réponse en haut.
0
ElementW Messages postés 4814 Date d'inscription   Statut Contributeur Dernière intervention   1 223
 
'lut, j'en profite pour passer mon message habituel...
Mais maintenant que j'ai fait une fiche de FAQ, j'en profite:
PHP: L'extension MySQL est obsolète
1
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Bonjour
il manque un WHERE dans ta requête.
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
Merci de ta réponse mais si tu pouvais juste un peu mieux m'indiquer le chemin :/
Ou ça ?
Merci
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
repond
0
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Où? ?....dans ton SELECT ....
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
MERCI !
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
Mais ca ne fonctionne toujours pas !!
0
clé de 12 Messages postés 141 Date d'inscription   Statut Membre Dernière intervention   1
 
ma réponse a disparu, je ne sais pourquoi.
Tout d'abord, tu nomme une variable session sans lancer de sessin! n'est ce pas une variable post?
ensuite tu a un $i=0 donc tu vas afficher la 1ere ligne de ton fichier
tu devrais faire un truc style
session_start();
$login=$_SESSION['login'];
ou $login=$_POST['login']; a toi de voir

ensuite tu fais ta requete à partir du login
$requete="select * from membre where login = '$login'";

Tu execute ta requete en testant l'unicité de ta reponse
mysql_num_rows
et tu lances ton mysql_fetch_row ($requete, $connexion)
et tu recupères chaque champ pour renseigner tes <td>
ca devrait marcher
@+
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
Merci de ta réponse j'ai des petits soucis d'internet je te tiens au courant !
0
Untsores Messages postés 12 Date d'inscription   Statut Membre Dernière intervention  
 
Bon voila internet régler !
alors j'ai bien essayer ce que tu ma dit mais il me dit:
Parse error: syntax error, unexpected 'SELECT' (T_STRING) in /public_html/tester/member.php

voici les scripts sur ma page:
ca commence avec ça (pour vérifier si il est bien connecté:
<?php
session_start();
require_once('config.php');


if(!isset($_SESSION['login'])) {
header('Location: conacces.php');

  exit;
}

?> 


Ensuite un exemple de mon script avec ton SELECT qui ne fonctionne pas,

<? $login=$_SESSION['login']; ?>
<div align="center" class="titre"><?php echo 'Bienvenue dans la zone membre ' . $_SESSION['login'] . ''; ?></div><br>
<?php //Affichage base solo
$i = "0";
//Selection de la table
	$query = "select * from membres;
	$result = MYSQL_QUERY($query);
   $result = mysql_query("SELECT * FROM membres where login = '$login'");
   $total= mysql_fetch_array($result);  
       
  	    $t_id = mysql_result($result, $i, "id");
		$t_pseudo = mysql_result($result, $i, "login");
		$t_age = mysql_result($result, $i, "age");
		$t_dprt = mysql_result($result, $i, "depart");
		$t_pays = mysql_result($result, $i, "pays");
		$kos= mysql_result($result, $i, "kos");
		$t_inscritle = mysql_result($result, $i, "date");                                    
  ?>
	<table width="300" border="2" align="center" cellpadding="3" cellspacing="2">
  <tr>
    <td>	
	<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><div align="center" class="aff2"><?php echo "$t_pseudo"; ?></div></td>
    </tr>
  <tr>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Départment : </span><span class="aff2"><?php echo "$t_dprt"; ?></span></div></td>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Pays : </span><span class="aff2"><?php echo "$t_pays"; ?></span></div></td>
  </tr>
  <tr>
    <td><div align="center"><span class="nom">Age : </span><span class="aff2"><?php echo "$t_age"; ?></span></div></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center"><span class="nom">Inscrit le : </span><span class="aff2"><?php echo "$t_inscritle"; ?></span></div></td>
    </tr> 
	  </table>
    </td>
  </tr>
</table>


Merci
0