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
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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.