Jump to content

Read Form Then Post


ChidoriSoul

Recommended Posts

Ok, so I am trying to create a user profile, so I want it to show the user's name, and I was wondering how to get that from the table that was used for Register, and then write the ID for it.Thanks!Shadow

Link to comment
Share on other sites

Are you saying you want a form in register.php to put information into a mysql table?or that you want another form to pull information from the mysql table and put information into a different mysql table?

Link to comment
Share on other sites

I am trying to make like a User Profile like this:Name: It automatically gets thereID: etc:I want to know when a users registers, a page gets added with all of the information, and it will stay there.

Link to comment
Share on other sites

You don't make a new page when they register, you just have one PHP profile page where you tell it which user to get the profile for. e.g.:profile.php?userid=10The page looks up that user's information and displays the information where you want it.Or, if they're logged in and you're using the session to keep track of who is logged in, you can also just have the profile page check the session to get the user ID instead of sending it in the URL. That's how they do it in this forum, since the session tracks who's logged in the link to the "My Controls" page is this:http://w3schools.invisionzone.com/index.ph...rCP&CODE=00It doesn't say which user it is, it gets that from the session.

Link to comment
Share on other sites

you don't need to create a new page, you will have one page that will display information from the database based on the ID.if you get to a page with "profile.php?userid=1", $_GET['userid] has a value of 1.then have your php take information from the row in the database table where userid is equal to $_GET['userid']

Link to comment
Share on other sites

  • 2 weeks later...

So, what is wrong with this linkMy PageMy code for the page is

<?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());$CheckAmountOfUsers = mysql_query("SELECT * FROM `users`, $con);$AmountOfUsers = mysql_num_rows($CheckAmountOfUsers);$i = 1;while($i >= $AmountOfUsers) {$GetUserInfo = mysql_query('SELECT * FROM `user` WHERE `ID` = ''.$i.''", $con);$UserInfo = mysql_fetch_array($GetUserInfo);echo "<a href=\'view_profile.php?user_id='.$i.'\'>".$UserInfo["Username"]."</a><br />";$i++;}GET["ID"]."'", $con);$array = mysql_fetch_array($query);$Username = $array["username"];<!--stuff-->$query = mysql_query("SELECT * FROM `users` WHERE `ID` = '". ?>

Link to comment
Share on other sites

echo "<a href=\'view_profile.php?user_id='.$i.'\'>".$UserInfo["Username"]."</a><br />";

Count your quotes.Also this line is a bit random:
GET["ID"]."'", $con);

Link to comment
Share on other sites

That's not using the database efficiently. First you select all data from the users table, then count how many there are, then start a counter and select each user again individually. So you're sending 1 query per user, in addition to the one to get everyone. You're assuming that the IDs are numbered sequentially because you're printing the value of the counter for the ID instead of the actual ID from their user row, but what happens if you delete a user and remove that ID? The numbering will get messed up. You should only select the user data once, select the username and ID (or other fields if you need them, not necessary to select *), and then loop through the users and print each one out. It seems kind of strange to select everything, get the count, and then loop through and select each user again, and print the counter for the ID when you could just print the ID itself. You've got other problems with the while loop, but those will go away if you change how you're doing it.

Link to comment
Share on other sites

When a user registers it needs to create a user profile page and have his id attached to it, then when you go to the page it takes that id and retrieves all the information that is related to that id.Understand?

Link to comment
Share on other sites

Forgive me if i'm wrong but i think a simple mysql select query would suffice:say the page is "yourpage.com?id=10"

<?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());$selectUser = mysql_query("SELECT * FROM users WHERE id = '" . $_GET['id'] . "' ");$user = mysql_fetch_array($selectUser);$username = $user['username'];//etc?>

Hope this helps :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...