Jump to content

Personal touch to site


dirty_student

Recommended Posts

Hi All,

Hope somebody can help... the problem is that i have created a log in page for my site using dreamweaver MX and php mysql everything works fine but i would like to display the firstname and surname of the user that has logged in on the next page. My database is set up that the username and password fields are in the same table as the data i want to display if you will

Student_Number
User_Name
Password
Surname
First_Name

if you can understand what i mean i would appriciate some help!!!!
Link to comment
Share on other sites

welcome to the forums! hope we can help you out here.

if i understand what you're after, once someone successfully logs it, you ought to keep a session variable with their user_id (or even just their username) so that you can pull their information on any future pages they hit. once you do that, you can run a simple query at the top of the page pulling their information from the database. use it wherever you want on the rest of the page.
Link to comment
Share on other sites

Well first off every page in your site needs to start with
session_start();
Even the login page. After they fill in there username and password, and are authenticated you store the username in a session. Here is some code I use once the user has entered his info

[code]if(isset($_POST['username'])){
$username = $_POST['username'];
$password = md5($_POST['password']);
$getuser = "SELECT * from users WHERE username = '$username' AND password = '$password'";
  $result = mysql_query($getuser) or die (mysql_error());
    $r = mysql_fetch_array($result);
    $qualify = mysql_num_rows($result);
if($qualify > 0){
$_SESSION['username'] = $_POST['username'];
}[/code]

Now whenever you want to use the persons username you just reference the session id

[code] echo "Hello $_SESSION['username'] welcome to my site";[/code]

Ray
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.