Gurzi Posted August 3, 2006 Share Posted August 3, 2006 Hy there...I have one question about managing files..I have one form with 2 input type="text" and i want to write the $_POST data on the file..Ok, it works, but my problem is i want that the next registration be on a new line, so, when i open te agenda.txt(agenda is adress book in Portuguese, btw ;D) the data is written on a new line...I wrote the "\n" but i a single char appears on the .txt and the new registration occurs next the last one , instead of a new line the code is :if(isset($_POST['Adicionar'])){ $handle = @fopen($file, "a+") OR die("Failed to open the file " . $file . "\n"); $nome = $_POST['Nome']; $email = $_POST['Email']; @fwrite($handle, $nome . "|-|"); @fwrite($handle,$email ); @fwrite($handle, "\n");}thnks a lot Link to comment https://forums.phpfreaks.com/topic/16399-files-doubt/ Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 is the char a little boxIts something to do with encoding. Plain text does not read \nopen it in a rich text editor (Word, Dreamweaver ...) and it will be on a new line Link to comment https://forums.phpfreaks.com/topic/16399-files-doubt/#findComment-68255 Share on other sites More sharing options...
Gurzi Posted August 3, 2006 Author Share Posted August 3, 2006 ok, i didn't know that point...i tryed a different way, and it's fine.. but i dont understand why.. because i think that is the same thing : $handle = @fopen($file, "ab+") OR die("Failed to open the file " . $file); $nome = $_POST['Nome']; $email = $_POST['Email']; $gravar = $nome ."|-|". $email; @fwrite($handle, "$gravar\r\n");and now, the file jump to the next line Link to comment https://forums.phpfreaks.com/topic/16399-files-doubt/#findComment-68270 Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 \r is return\n is new line\t is tabas txtpad is a plane text editor is uses \r not \n i guess Link to comment https://forums.phpfreaks.com/topic/16399-files-doubt/#findComment-68272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.