Schlo_50 Posted November 19, 2007 Share Posted November 19, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.