Jump to content

[SOLVED] Help doing script!!


juapo2

Recommended Posts

Hi,

I have a site running on free web hosting.

I have various powerful scripts but i need help coding something some people may say is easy...

 

I need a form, where my users add their e-mail adress to receive newsletter, i just need them to write their e-mail adress, and make the e-mail adress go into a .txt file, something like emails.txt

 

I dont need script to send the newslettter or to unsubcribe them, just that their email adress goes into the .txt file,

 

I would appreciate if you could help,

 

Thany YOU.

Link to comment
https://forums.phpfreaks.com/topic/82898-solved-help-doing-script/
Share on other sites

Form to have on your page:

<form action='addemail.php' method='GET'>
<input name="email" type="text" />
<input name="submit" type="submit" />
</form>

 

this php code should be in addemail.php (assuming the form above is used):

<?php
if (isset($_GET['submit'])){

$email = $_GET['email'];

//adding a new line character so that each email address has its own line
$email = "$email \n";

//opening the textfile for writing
$textfile = fopen("emails.txt","a");

//writing the email
fwrite($textfile, $email);

//closing the textfile handle
fclose($textfile);
}
?>

 

It's a very simple, basic script, but it will get the job done :)

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.