Jump to content

Extract username data


vividona

Recommended Posts

hi friends,

 

plz someone explain this for me:

 

I have user table. I fetched all data in this table nicely. Then I put the names of usernames in a shape of links. Till here all work good.

But as I said I put usernames in links. I need when I click on any username link. extract the full data of this username. e.g. edit the account, change password, change email etc.

Link to comment
https://forums.phpfreaks.com/topic/156950-extract-username-data/
Share on other sites

The link for the username should take you to another PHP file, passing along the userid of the user. Of course, I hope you have a unique ID field for each user or this won't work. If you don't have that field, please read up on DB normalization. In that PHP file, use $_GET superglobal to get the userid and then query the DB for info about that user id.

 

Example (this is just a rough sketch and it is by no means a full code. So if you choose to copy and paste, please don't badger me if it works. I do not guarantee anything)

 

The URL - http://www.mydomain.com/userprofile.php?id=4

Say that's the URL you want to redirect the user when clicked on the username. Then create a userprofile.php.

 

userprofile.php

<?php

// use $_GET to get the id field
// The id field is the "id=4" part in the URL
// if all goes well, $id should equal to 4.
$user_id = $_GET['id'];

// here's where it's up to you to query the DB

 

Hope this helps,

Ken

Archived

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

×
×
  • 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.