Jump to content


how to show username after login?


9 replies to this topic

#1 fudgy

    Young Padawan

  • Members
  • Pip
  • 80 posts

Posted 23 July 2008 - 07:32 AM

well i want to know how to show the username of the member, the date they last logged in, and the date after they have logged in. can anyone tell me how to do this

this is the code i have for my page login snippit..(the file is saved as a .php)

the site code that displays the form V

<div id="login">
<div style="margin-left: 24px; overflow: scroll;width:235px;height:175px;">
<FORM METHOD="POST" ACTION="/user_system/redirect.php">
<font color="#999" face="Verdana" size="2px">
<INPUT TYPE="text" NAME="username" value="username" id="username" SIZE=14 MAXLENGTH=14></font><BR>
<font color="#999" face="Verdana" size="2px">
<INPUT TYPE="password" NAME="password" value="password" id="password" SIZE=14 MAXLENGTH=14></font>
<font face="Verdana"><font color="#999"><input type="checkbox" name="remember" value="Yes"></font><div style="font-family: Verdana;font-size:10px;">remember 
me</font></div><BR>
<font color="#999">
<INPUT TYPE="submit" NAME="submit" VALUE="login" style="font-family: Verdana;font-size:10px;"></font>
</FORM><div style="font-family: Verdana;font-size:10px;color:#999">
<a href="/user_system/emailpass.php">
click here to resend username & pass.</a></div>
<div style="font-family: Verdana;font-size:10px;color:#999">
<BR>
<a href="/user_system/register.php">
not registered? click here!.</a></div>
</div>
</div>

Edited by fudgy, 23 July 2008 - 07:47 AM.


#2 Tyson D

    Young Padawan

  • Members
  • Pip
  • 85 posts
  • Gender:Male
  • Location:Canada

Posted 24 July 2008 - 10:44 AM

I would recommend that you read up a bit about PHP sessions for an understanding of how this will work. There should be an abundance of tutorials on PHP sessions, use google! :)

Also... if you want help you'd probably want to post your php script code rather than the HTML form!

Edited by TysonD, 24 July 2008 - 10:45 AM.


#3 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 24 July 2008 - 10:51 PM

use mysql database, use sessions, and select from the user data table from that user's username.

#4 fudgy

    Young Padawan

  • Members
  • Pip
  • 80 posts

Posted 25 July 2008 - 11:40 PM

i did that well my friend told me this code...all credit goes to Sk8modz below! V

<php

$dbhost = 'host';
$dbuser = 'my name im not releasing';
$dbpass = 'my name im not releasing';
$dbname = 'my name im not releasing';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) OR die('Error connecting to mysql');

mysql_select_db($dbname);

$q = "SELECT * FROM authorize WHERE username = ". $username;
$r = mysql_query($q, $conn);
$userdata = mysql_fetch_array($r);

echo 'Username: '. $userdata['username'];
echo 'Last Login'. $userdata['last_login'];
echo 'Email'. $userdata['email'];

?>

and i put that on the page witht he html form what after u login the page redirects u to, and it doesnt show up how come?

can anyone just give me the answer and not that stupid google it or search tutorials >.>

#5 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 26 July 2008 - 12:03 AM

You don't have your username defined...

in the login page, at the beginning of the php, add session_start();

then if everything is okay and you begin to redirect the user to the members page (the page with the code you provided), add this:

$_SESSION['username'] = $_POST['username'];

then copy and paste this:

<php

session_start();

$username = $_SESSION['username'];

$dbhost = 'host';
$dbuser = 'my name im not releasing';
$dbpass = 'my name im not releasing';
$dbname = 'my name im not releasing';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) OR die('Error connecting to mysql');

mysql_select_db($dbname);

$q = "SELECT * FROM authorize WHERE username = ". $username;
$r = mysql_query($q, $conn);
$userdata = mysql_fetch_array($r);

echo 'Username: '. $userdata['username'];
echo 'Last Login'. $userdata['last_login'];
echo 'Email'. $userdata['email'];

?>

That should help you, and it should work

Edited by bigdfbc2008, 26 July 2008 - 12:07 AM.


#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 July 2008 - 01:08 AM

View Postfudgy, on Jul 25 2008, 10:40 PM, said:

can anyone just give me the answer and not that stupid google it or search tutorials >.>
If you want to be given the answer, you should try the Hire or Offer Professional Services forum. This forum is for learning, unfortunately Googling and searching for tutorials is a necessary part of learning.

http://www.pixel2life.com/tutorials/php_co...ership_scripts/ <- A great place to look for how people have done what you're asking to do.

#7 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 26 July 2008 - 11:06 AM

Was my response not sufficent enough for you???

#8 fudgy

    Young Padawan

  • Members
  • Pip
  • 80 posts

Posted 27 July 2008 - 01:49 PM

yes it is sorry i never saw it, thnx guyS!


EDIT: no it did not work =(

guess ill keep lokin

BUMP I NEED THIS BADLY

Edited by rc69, 13 August 2008 - 12:32 AM.


#9 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 13 August 2008 - 12:37 AM

1. Don't bump.
2. It's been 2 weeks. Surely you have tried some stuff of your own. As said earlier, if you want to be given the answer, post in the Hire or Offer Professional Services forum, otherwise, tell us where you're struggling with this and we'll try and help you through it.

For instance, you say the above did not work. What about it didn't work? Did you get any error messages? Did anything get selected from the database? Do you even have a database and if so, are the table/field names in the above code even correct? Are you even reading which username was entered?

I still recommend looking at the link i provided in my previous post. If you haven't taken the time to do that yet, then you must not need this that badly (no offense intended, that is just my opinion :)).

#10 fudgy

    Young Padawan

  • Members
  • Pip
  • 80 posts

Posted 13 August 2008 - 04:22 AM

View Postrc69, on Aug 13 2008, 12:37 AM, said:

1. Don't bump.
2. It's been 2 weeks. Surely you have tried some stuff of your own. As said earlier, if you want to be given the answer, post in the Hire or Offer Professional Services forum, otherwise, tell us where you're struggling with this and we'll try and help you through it.

For instance, you say the above did not work. What about it didn't work? Did you get any error messages? Did anything get selected from the database? Do you even have a database and if so, are the table/field names in the above code even correct? Are you even reading which username was entered?

I still recommend looking at the link i provided in my previous post. If you haven't taken the time to do that yet, then you must not need this that badly (no offense intended, that is just my opinion :) ).


ok i checked out the link you posted before, and i think i have to just make my own script cause the one i am added onto is just plain messed up. the form i am using on my php page, i dont even think it is getting and recieving the information the user has entered to logthem in, and log them out, this is plain stupid, but i think that is the problem, becuase i think the script bigdfbc2008 added would work, could you please message me if you are willing to help me with this little problem? please. i actually really do need this.

as for hireing some one, i dont have anymoney to offer or anything to offer to them.

-fudgy-





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users