How can I display a certain user after he/she logs in...?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

How can I display a certain user after he/she logs in...?

Post by cturner »

How can I display a certain user after he/she logs in then after he/she selects the my account link?
Here is the code that I have been working with but doesn't seem to be working for me:

Code: Select all

require "config2.php";
$usersid = $_POST['usersid'];
$query = "SELECT username, password, email FROM users WHERE username = '$usersid' LIMIT 1";
$result = mysql_query($query) or die("Could not select data from the database because: ". mysql_error());
while($row = mysql_fetch_array($result)){
	echo "<div class=borderbg>";
	echo "<b>Edit your Account</b>";
	echo "<form action=account.php method=post>";
	echo "Username: ".$row['username']."<br> E-mail address: <input name=email type=text value=".$row['email']."><br /><a href=comments.php>Edit comments</a> <br /> Current password: <input name=currentpassword type=text> <br /> New password: <input name=newpassword type=text><br /> Confirm new password: <input name=newpassword2 type=text> <br /> <input name=submit type=submit value=SAVE> <input name=reset type=reset value=RESET>";
	echo "</form></div>";
}
mysql_close();
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

In order to maintain state, you are going to need to use sessions of some sort. PHP Native sessions are pretty good. You may want to look at those.
Post Reply