/    Sign up×
Community /Pin to ProfileBookmark

Writing to text files via a form

What would be the best way to have user inputted data be writen to a text file which sits on a server? In order words, I have a form with one textbox and a submit button. When something is typed in the textbox and then submitted I want to have that written to a text file that will be on a server.

Two things to note, I want each entry seperated by its own line and I don’t want the previous entry being deleted by a new one. I want to be able to go back and see all inputted data in that textbox.

I’ve done quite a bit of searching around to find an answer to this without success. Any ideas? Tutorials or actual code would greatly help.

Thank you.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@WebnerdJul 06.2005 — Use PHP:

<i>
</i>if(isset($_POST["submit"])){
$file="entries.txt";
$fp=fopen($file,"a+") or die("Cannot open $file.");
fwrite($fp,$_POST["yourfield"]);
fclose($fp);
}
Copy linkTweet thisAlerts:
@ZeethauthorJul 06.2005 — Exactly the same as yours, but in a fewer lines, I have:

[code=php]$fp = fopen("textfile.txt", "a+");
fwrite($fp, $search);
fclose($fp);[/code]



Now, how would I get each entry in the search box to have its own line in the textfile? Its gets hard to read having entry after entry all on the same line.
×

Success!

Help @Zeeth 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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