hi everyone... i am writing a php to file write script. i have the info entering from a form on a separate page. below is the code i have written however i need to get the info to be entered on a new line each time its entered. <? $name = $_POST['name']; $message = $_POST['message']; $fp = fopen('./messages.txt', 'a'); fwrite($fp, '' . $name . ': ' . $message . ''); fclose($fp); ?> Code (markup): where abouts can i enter the new line command and what is it? Thanks =]
fwrite($fp, '' . $name . ': ' . $message . '\n'); Code (markup): I also prefer for html: echo "<br />"; Code (markup): I have it saved as a one key macro in my editor. To add: windows may need \r\n Some text editors may not be able to show the line break, however...for obvious reasons.
thank you Eager2Seo, i have now changed it to add to a .html file rather than a .txt file and used the <br /> rather than \n. now i have done this the page that includes the .html file reads the <br /> and puts the new lines in again thank you very much
You need to wrap double quotes around the \n, so it evaluates. Also for cross-server compatability consider using \r\n