0

what im trying to do:
1. register
2.login
3.go to "my profile" where user are able to edit their username, password and so on.

my problem:
i have success to do the register n login page, but after login, the page "my profile couldn't show all the details that the user had key in in the register page.

*all the data had been stored in the database, there is no problem for register and login page. the only problem is i coundn't call out all the details into "my profile" page when the particular user login.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by alex0514
0

hi..

i can understand ur prob..

after loggin in, did u put your username into the session variable ?

if the login is successful, put the username in the session variable, then redirect the user to the profile page..

there u can get the user name from the session variable, use it in the query to get their own profile , then display..

i hope u understand.. :)

0

im using dreamweaver cs3, is there any example of doing it that i can refer to?i have put the username in the session variable, i can login and whn i login, it is empty but only a "my profile" show on that page. below are the coding for "my profile" page:

<?php include 'include/header.php'; ?>
<?php 
$user=$_SESSION['username'];

mysql_connect ("localhost", "root", "") or die ('My SQL Error: ' . mysql_error());
mysql_select_db ("telphone");
$fetch = mysql_query("SELECT * FROM `member` WHERE username='$user'") or die("MySQL Login Error: ".mysql_error()); 

while($myfetch=mysql_fetch_array($fetch)){

$id = $myfetch[userId];
}
?>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="100%"><p><p>
      <p align="center" class="biglabel">My Profile</p>
      <p></p>
<?php
session_start();
$username=$_SESSION['username'];

mysql_connect ("localhost", "root", "") or die ('My SQL Error: ' . mysql_error());
mysql_select_db ("telphone");
$stuff = mysql_query("SELECT * FROM `member` WHERE userId='$id'") or die("MySQL Login Error: ".mysql_error()); 

while($jj=mysql_fetch_array($stuff)){

$userId = $jj[userId];
$username = $jj[username];
$pwd = $jj[pwd];
$email = $jj[email];
$fName = $jj[fName];
$lName = $jj[lName];
$gender = $jj[gender];
$ic = $jj[ic];
$dob = $jj[dob];
$addr = $jj[addr];
$city = $jj[city];
$poscode = $jj[poscode];
$country = $jj[country];
$phnum = $jj[phnum];

echo("<table width=80% border=0 align=center cellpadding=0 cellspacing=0>");
          echo("<tr>");
            echo("<td><table class=table width=100% border=0 cellpadding=3 cellspacing=1>");
                echo("<tr>");
                  echo("<td width=30%>Username</td>");
                  echo("<td width=1%>:</td>");
                  echo("<td width=60%>$jj[username]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Password</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[pwd]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>E-mail Address</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[email]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>First Name</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[fName]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Last Name</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[lName]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Gender</td>");
                  echo("<td>:</td>");
                  echo("<td> $jj[gender]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>IC Number</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[ic]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Date Of Birth</td>");
                  echo("<td>:</td>");
                  echo("<td> $jj[dob]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Address</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[addr]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>City / State</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[city]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Poscode</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[poscode]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Country</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[country]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>Phone Number</td>");
                  echo("<td>:</td>");
                  echo("<td>$jj[phnum]</td>");
                echo("</tr>");
                echo("<tr>");
                  echo("<td>&nbsp;</td>");
                  echo("<td>&nbsp;</td>");
                  echo("<td><font color='#FFFFFF'>
                            <div align=right>
                             <a href='profile2.php?username=$username&pwd=$pwd'>
                             <input type=submit value='Change Password' name=submit /></a>
                             <a href='profile.php?username=$username&email=$email&fName=$fName&lName=$lName&gender=$gender&ic=$ic&dob=$dob&addr=$addr&city=$city&poscode=$poscode&country=$country&phnum=$phnum'>
                             <input type=submit value='Update Profile' name=submit /></a>
                             </div></td>");
                echo("</tr>");
            echo("</table></td>");
          echo("</tr>");
        echo("</table>");
        }
?>
     </td>
  </tr>
</table>
<br />

<?php include 'include/footer.php'; ?>

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.