Jump to content

php script problem


LukasNep

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.