Jump to content

Displaying Links to specific users


Schlo_50

Recommended Posts

Hey guys,

 

I am currently working on a project whereby users login to my website and then using a form add new quick links/tabs to their navigation bar. So for instance if the user had 'home/search engines/favourites' as links on their navigation bar and they wanted to add auction sites as a group link they fill out the form which then posts the data into a flat file database. (usertabs.txt)

 

So far i can make the form send the link name, URL and attach the username of the person adding links so to make a id for the link name and URL. So in the flat file the structure is presently:

 

username(unique)|Link name|URL

schlo_50|Google|http://www.google.com

 

What i want to do is write some code to say, 'when Joe Bloggs is logged in, display all links uploaded by him by searching usertabs.txt and outputting any link name and URL that follows his username.'

 

So far i have:

 

function displaytab(){

$usertabs = $_SESSION['userName'];

$file = file("usertabs.txt");
foreach($file as $key => $val){
$data[$key] = explode("|", $val); 

  $user = $data[$key][0];
  $link = $data[$key][1];
  $url = $data[$key][2];
}

if ($usertabs == $user){
echo $link, $url;
}
}

 

This is what i have so far, it's just i need something that works better with sessions.. If i log in with one user and upload a new link the script works but if i then log out and login with a different username the links aren't outputted.

 

I've designed that code to search the whole text file for any entries matching the users username and output it but it doesn't do it very well. Help anyone? Maybe its my file search method?

 

Help please,

Regards

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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