Forum Moderators: coopster
I am greatful for the previous help from members here.
The problem I am having, is that when a member goes to update their info, the system is retrieving the last member who joined informaiton and not there own.
I was originally getting a blacnk form but now this is getting filled in correctly just not the right info for each user.
I wa advsied to read up on sessions but as I am very new to php, this is taking me forever.
I would be very grateful for any help on this.
If you would like to see the login.php, members.php and update.php files please let me know
This is how the login.php starts
<?
include "header.php";
include ('vars.php');
session_start();
$_SESSION['id'] = $id;
if (isset($work)) {
// FIND USER IN DB
mysql_connect($dbhost,$dblogin,$dbpass) OR DIE ("Wrong username or password");
mysql_select_db($db) OR DIE("No such database");
$query = "SELECT * FROM members WHERE user = '$user'";
$result = mysql_query($query);
echo mysql_error();
$number = mysql_num_rows($result);
if ($number == 1) {
$a1 = mysql_result($result,0,'first_name');
and this is how the members.php file starts
<?
include 'vars.php';
include 'header.php';
session_start();
$_SESSION['id'] = $id;
{
mysql_connect($dbhost,$dblogin,$dbpass) OR DIE ("Wrong username or password");
mysql_select_db($db) OR DIE("No such database");
$query = "SELECT * FROM `stats` WHERE `user` = '$user'";
$result = mysql_query($query);
$number = mysql_num_rows($result);
for ($i=0;$i<$number;$i++) {
$n[1] = mysql_result($result,$i,'user');
$n[2] = mysql_result($result,$i,'recieved_lp');
$n[3] = mysql_result($result,$i,'recieved_tot')
and finally the update.php file
<?
include 'vars.php';
include 'header.php';
session_start();
mysql_connect($dbhost,$dblogin,$dbpass) OR DIE ("Wrong username or password");
mysql_select_db($db) OR DIE("No such database");
$query = "SELECT * FROM `members` WHERE id=" . $_SESSION['id'];
$result = mysql_query($query);
for ($i=0;$i<$number;$i++) {
$n[1] = mysql_result($result,$i,'id');
$n[2] = mysql_result($result,$i,'first_name');
Please can anyone guide me in the right direction as to where I am going wrong...
many thanks
John
I am guessing that if you output the actual query that is being used here
$query = "SELECT * FROM `members` WHERE id=" . $_SESSION['id'];
you may find that it is not correct. It sounds like the problem is somewhere between setting the id to the session and the query to grab the user's information.