Jump to content

Writing a string to a file.


ryanfilard

Recommended Posts

I have to create a script that writes a user's email to a .txt file. I am using the code below and it does not seem to be working.

<?PHP 
//Data to write
$newsletterinfo = $REQUEST['email'];
//Open the file directory
$fdir = fopen('newsletter.txt');
//Write user email
fwrite($fdir, $newsletterinfo);
//Close the connection
fclose($fdir);
?>

 

Link to comment
https://forums.phpfreaks.com/topic/240312-writing-a-string-to-a-file/
Share on other sites

I changed it but it still does not work. I am doing something wrong?

<?PHP 
//Data to write
$newsletterinfo = $_REQUEST['email'];
//Open the file directory
$fdir = fopen('newsletter.txt');
//Write The Data
fwrite($fdir, $newsletterinfo);
//Close the connection
fclose($fdir);
?>

 

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.