Results 1 to 3 of 3

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

  1. #1
    Join Date
    Aug 2013

    PHP Flat File .txt Issue "Social Networking Site"

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

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

    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
    Voorheesville NY USA
    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
    Why not use a SQLite database if you don't want to use a SQL database?
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

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