www.webdeveloper.com
Results 1 to 3 of 3

Thread: PHP Flat File .txt Issue "Social Networking Site"

  1. #1
    Join Date
    Aug 2013
    Posts
    1

    PHP Flat File .txt Issue "Social Networking Site"

    Ok I am only having one problem. Here is the code:

    <?php
    $myfile = "bio.txt";
    if (isset($_POST['ta'])) {
    $newData = nl2br(htmlspecialchars($_POST['ta']));
    $handle = fopen($myfile, "w");
    fwrite($handle, $newData);
    fclose($handle);
    }
    ?>

    This is the main line I'm having an issue with: " $myfile = "bio.txt"; "

    I would like to automatically add this "bio.txt" file in the folder of the current logged in user.

    For example, It works if I do it this way: " $myfile = "user/johndoe/bio.txt"; "
    " $myfile = "user/greg/bio.txt"; "
    " $myfile = "user/tammy/bio.txt"; "

    What I want is something like this " $myfile = "user/$u/bio.txt"; or " $myfile = "user/$username/bio.txt"; " but neither of those work. I need this one line to auto detect the user who is logged in so when that user updates his/her "Biography" section it will automatically edit and read their "bio.txt" which is in their user folder along with their pics, vids, mp3s, and other files.

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    546
    Well, you don't show us anything regarding a login, but if you want to know who the user is, you have to ask them, no? Once you do that, then you can capture the name and save it and use it just as you proposed above.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,213
    Why not use a SQLite database if you don't want to use a SQL database?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles