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: [email protected]@[email protected] and i need to have in lines like: [email protected] [email protected] [email protected] 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. 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 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. 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"); ?> 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 "[email protected]" emails 1,2,3 and here is report of mailing.txt: [email protected]@[email protected] I tryed some choses of /n /r, thinks like that i found in google but still same problem. 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 [email protected]@[email protected]? Are you echoing to the browser? 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 = "[email protected]\r\n"; $email2 = "[email protected]\r\n"; $email3 = "[email protected]\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) [email protected] [email protected] [email protected] Link to comment https://forums.phpfreaks.com/topic/241327-php-script-problem/#findComment-1239646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.