Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Richard Duffy
16,488 PointsCreate a file from a form input using PHP
Hello can someone help me, I need to create a file from a form input using php.
3 Answers
Andrew McCormick
17,730 PointsPretty broad question, but basically you would POST the values from the form to a page that would process the $_POST variable and write it's contents to a file.
The basics are fopen(), fwrite(), fclose() .
You can also use the all in one file_put_contents
Yorick Toma
742 PointsOr is this user trying to generate a form using PHP in that case its just as easy as:
<?php
echo '<input type="text" name="example" id="example" />';
Richard Duffy
16,488 PointsThanks.
Andrew McCormick
17,730 PointsAndrew McCormick
17,730 Pointsedit: I changed the tag from General Discussion to PHP