idutchie Posted April 23, 2010 Share Posted April 23, 2010 Hello, I have made a page that allows a user to enter their name and a message into a form. After they click submit, the information is appended to a text file. I am having a problem though getting a line break after each field sent. Here is my code so far: <?php $myFile = "myfile.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = $_POST['name']; fwrite($fh, $stringData); $stringData = $_POST['message']; fwrite($fh, $stringData); fclose($fh); ?> How can I make it so that there is a line break added to the text file after the 'name' variable and 'message' variable? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/199547-help-with-a-line-break/ Share on other sites More sharing options...
Alex Posted April 23, 2010 Share Posted April 23, 2010 You mean you want to append a line break to the end of each line written to the file? fwrite($fh, $stringData . PHP_EOL); Quote Link to comment https://forums.phpfreaks.com/topic/199547-help-with-a-line-break/#findComment-1047377 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.