firecat318 Posted April 24, 2008 Share Posted April 24, 2008 On my website, I want to setup a system where a user will be allowed to start and maintain a small profile. They will also be able to browse and view other people's profiles. I have run into a problem though, I don't have the wildest idea of how to go about giving each profiles its own URL. In my database, each profile gets its own id number, but I don't know how to go about and put this into the URL. For example.. http://mysite.com/index.php?id=32 Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/ Share on other sites More sharing options...
monkeytooth Posted April 24, 2008 Share Posted April 24, 2008 Well.. depends on how you display the links to get to the profiles you wanna allow access to.. If your manually putting them onto a master page then its simply putting the URL together like you did in your orginal post.. then by using the $_POST or $_GET function to grab the variable from the URL and input it to your database query in your script. From there its all about what I refer to as cosmetics.. It's all about how you wanna do it.. how you wanna make it pull data from the initial links to the profiles.. to actually displaying the profiles from a link.. would be happy to help, got questions shoot.. Hell if it can wait til morning when I get out of my job I may opt in to help you build up something nice just for the hell of it, more so if you wanna throw me some credit in the form of a link.. your using php and mysql I assume? I dunno, food for thought.. Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-525782 Share on other sites More sharing options...
firecat318 Posted April 24, 2008 Author Share Posted April 24, 2008 Say a user just registered, and they are user number 394 to register... how would you go about writing code that would allow them to view their profile using the end code ?id=394, or something along those lines. I am at a loss of even where to put the code, along with what to write. Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-525784 Share on other sites More sharing options...
monkeytooth Posted April 24, 2008 Share Posted April 24, 2008 Well assuming you already have people signing up, and building profiles based on what I am reading and my preception there of... Just poping id=783 isnt going to make it display.. Your going to have to make a code that will query the database based on the ID variable which in this example is 783.. using the $_POST or $_GET functions within PHP you get the variable from the URL/Link.. then you would make a query to the database that looks for that ID that has been gotten from the URL/Link and pull the info for that ID inspecific.. Then you have it take said data and code it to display what of that info and how much of that info you want displayed.. Unfortunately not knowing the structure of your database, the tables within for the information you wanna pull.. and other underlying factors.. I can't just pop out a code that will work for you, then again I'm still not at home, so I wouldnt be able to do much for you til then either way. The computers here at my job, I'm lucky to just be able to use this site.. Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-525791 Share on other sites More sharing options...
firecat318 Posted April 24, 2008 Author Share Posted April 24, 2008 Well.. i'll just post some details here and see if you can help me.. So far, I've just got one table, called users which has 5 rows, name, id, email, password, username (they use username and password to login). I don't know what other information you need. Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-526237 Share on other sites More sharing options...
firecat318 Posted April 24, 2008 Author Share Posted April 24, 2008 I just need help knowing where to put the $_GET statement to make it show up in the URL. Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-526358 Share on other sites More sharing options...
monkeytooth Posted April 29, 2008 Share Posted April 29, 2008 <?php $id = $_GET['ID']; $sq_hst = "localhost"; $sq_unme = "username"; $sq_pzwrd = "password"; $database = "table_name"; $dbconn = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or die("Error: " . mysql_error()); mysql_select_db($database) or die("Could not select database"); $query="SELECT * FROM asylum_poetry WHERE ID='$id'"; $result=mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $result = mysql_fetch_array( $result ); $name = $result1a['name']; $id = $result1a['id']; $email = $result1a['email']; $password = $result1a['password']; $username = $result1a['username']; ?> <html>.................. <?php echo $name; ?> ...................... <?php echo $id; ?>................ </html> That what you mean? Link to comment https://forums.phpfreaks.com/topic/102656-user-profiles/#findComment-529617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.