Page 1 of 1

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

Posted: Sun Aug 20, 2006 2:42 pm
by muffin mahon
Any help? Thanks!

Posted: Sun Aug 20, 2006 2:57 pm
by feyd
Explain more. Show some code.

Posted: Sun Aug 20, 2006 3:00 pm
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]

Posted: Sun Aug 20, 2006 3:04 pm
by feyd

Posted: Sun Aug 20, 2006 3:28 pm
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>

Posted: Sun Aug 20, 2006 3:37 pm
by feyd
The output of var_dump($_POST) may be of interest. I won't code it for you.

Posted: Sun Aug 20, 2006 4:31 pm
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