How to use the PHP command "fwrite" with HTML form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
muffin mahon
Forum Newbie
Posts: 7
Joined: Sun Aug 20, 2006 2:02 pm

How to use the PHP command "fwrite" with HTML form

Post by muffin mahon »

Any help? Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Explain more. Show some code.
muffin mahon
Forum Newbie
Posts: 7
Joined: Sun Aug 20, 2006 2:02 pm

Post by muffin mahon »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

$myFile = "log.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);
I got that code online.

I want to have a little questionaire with html form boxes, and then when the user hits submit I want it to send the data in the boxes to my log.txt file.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

muffin mahon
Forum Newbie
Posts: 7
Joined: Sun Aug 20, 2006 2:02 pm

Post by muffin mahon »

I cant get this to work! Can you post some code I can copy/paste? I'm a noob =(. I wanna use this as my form boxes:

Code: Select all

<html>
<body>

<form action="anything.php" method="post">
Name: <input type="text" name="name"/>
Age: <input type="text" name="age"/>
<input type="submit"/>
</form>

</body>
</html>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The output of var_dump($_POST) may be of interest. I won't code it for you.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Did you need a new thread for this?

I think that you should read:

http://us2.php.net/manual/en/tutorial.forms.php
Post Reply