ball420 Posted October 8, 2007 Share Posted October 8, 2007 i would like to have user input saved as a txt file or html to the server instead of emailing the info to me anyone know of any good examples to follow or tutorials ect. thanks again for the replies Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/ Share on other sites More sharing options...
kenrbnsn Posted October 8, 2007 Share Posted October 8, 2007 This code snippet assumes the input is in a form: <?php $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen('user_input.txt',$mode); // open file fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file fclose($fp); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/#findComment-364733 Share on other sites More sharing options...
ball420 Posted October 8, 2007 Author Share Posted October 8, 2007 cool i'm going to give this a shot. thanks much apprecated Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/#findComment-364740 Share on other sites More sharing options...
ball420 Posted October 8, 2007 Author Share Posted October 8, 2007 it's not even creating it i'll show you how i have put it in my code. Mabey i'm not formating it right <?php if(isset($_POST['submit'])) { $errmsg = ''; // error message $nextstep = "nextstep.php"; $song1 = $_POST['song1']; $song2 = $_POST['song2']; $song3 = $_POST['song3']; $song4 = $_POST['song4']; $song5 = $_POST['song5']; $song6 = $_POST['song6']; $song7 = $_POST['song7']; $song8 = $_POST['song8']; $song9 = $_POST['song9']; $song10 = $_POST['song10']; $body = " $song1 /n $song2 /n $song3 /n $song4 /n $song5 /n $song6 /n $song7 /n $song8 /n $song9 /n $song10 /n " ; } $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen('user_input.txt',$mode); // open file fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file fclose($fp); header('Location: nextstep.php'); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/#findComment-364819 Share on other sites More sharing options...
The Little Guy Posted October 8, 2007 Share Posted October 8, 2007 http://phpsnips.com/snippet.php?id=21 Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/#findComment-364824 Share on other sites More sharing options...
prime Posted October 8, 2007 Share Posted October 8, 2007 have you thought of saving the entries to a database? personaly I find it a lot easier to handle data that way Quote Link to comment https://forums.phpfreaks.com/topic/72335-writing-to-a-text-document/#findComment-364942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.