/    Sign up×
Community /Pin to ProfileBookmark

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: ” [B]$myfile = “bio.txt”;[/B]

I would like to automatically add this “[B]bio.txt[/B]” file in the folder of the current logged in user.

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

What I want is something like this ” [B]$myfile = “user/$u/bio.txt”;[/B] or ” [B]$myfile = “user/$username/bio.txt”;[/B] ” 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.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmAug 23.2013 — 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.
Copy linkTweet thisAlerts:
@rootAug 23.2013 — Why not use a SQLite database if you don't want to use a SQL database?
×

Success!

Help @Legion13 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...