LukasNep Posted July 7, 2011 Share Posted July 7, 2011 Hello, I have problem with this script. This script is for newsletter system and writing emails to "mailing.txt" file. Problem is that its in line like this: mail@mail.commail@mail.commail@mail.com and i need to have in lines like: mail@mail.com mail@mail.com mail@mail.com there is my script: <?php $email = $_POST['email']; $file = fopen("mailing.txt", "a"); fwrite($file, "\n" . $email); fclose($file); header("Location: mailing_thankyou.php"); ?>[code] Thank you, have nice day. Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/ Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 <?php $email = $_POST['email']; $file = fopen("mailing.txt", "a"); fwrite($file, $email."\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> should work, depending on the OS you are using Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239617 Share on other sites More sharing options...
LukasNep Posted July 7, 2011 Author Share Posted July 7, 2011 <?php $email = $_POST['email']; $file = fopen("mailing.txt", "a"); fwrite($file, $email."\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> should work, depending on the OS you are using Win 7. Thank you for that but it still wont work. Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239629 Share on other sites More sharing options...
AyKay47 Posted July 7, 2011 Share Posted July 7, 2011 oh okay you're using windows..then you'll want <?php $email = $_POST['email']; $file = fopen("mailing.txt", "a"); fwrite($file, $email."\r\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> or also <?php $email = $_POST['email']; $file = fopen("mailing.txt", "at"); fwrite($file, $email."\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239630 Share on other sites More sharing options...
LukasNep Posted July 7, 2011 Author Share Posted July 7, 2011 oh okay you're using windows..then you'll want <?php $email = $_POST['email']; $file = fopen("mailing.txt", "a"); fwrite($file, $email."\r\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> or also <?php $email = $_POST['email']; $file = fopen("mailing.txt", "at"); fwrite($file, $email."\n"); fclose($file); header("Location: mailing_thankyou.php"); ?> Still the same. I tryed 3 "test@test.com" emails 1,2,3 and here is report of mailing.txt: test1@test1.comtest2@test2.comtest3@test3.com I tryed some choses of /n /r, thinks like that i found in google but still same problem. Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239636 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2011 Share Posted July 7, 2011 How are you generating the output that shows test1@test1.comtest2@test2.comtest3@test3.com? Are you echoing to the browser? Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239645 Share on other sites More sharing options...
TeNDoLLA Posted July 7, 2011 Share Posted July 7, 2011 Just tested this and works, could also replace the three functions fopen, fwrite, fclose with file_put_contents. $dir = '../test/test.txt'; $email1 = "test1@test1.com\r\n"; $email2 = "test2@test2.com\r\n"; $email3 = "test3@test3.com\r\n"; file_put_contents($dir, $email1, FILE_APPEND); file_put_contents($dir, $email2, FILE_APPEND); file_put_contents($dir, $email3, FILE_APPEND); Has this in file test.txt (using windows) test1@test1.com test2@test2.com test3@test3.com Quote Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239646 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.