Creating an email collecting button, help please

Discussion in 'HTML & Website Design' started by Schueis, Sep 18, 2008.

  1. #1
    I am not a coder, but I am trying to learn.

    I need to make a form button, which I already have made. However, I don't know how to make it do the following.

    I need it to be an email submit button, where it would collect the email addresses, and submit them as text into another file on my server. That way in the future, I can come back and collect these emails to send enewsletters. Any ideas guys? Thanks!
     
    Schueis, Sep 18, 2008 IP
  2. shahilroyhere

    shahilroyhere Well-Known Member

    Messages:
    189
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Which platform your site rus on?
    I mean php, jsp, asp or basic html.
    This thing can easily be done with php, if your sever has php support.

    Form:

    <form name="form1" method="post" action="submit.php">
    TEXTAREA NAME=usertxt COLS=20 ROWS=5></TEXTAREA>
    <p align="center">
    <input type="submit" name="Submit" value="Submit">
    </p>
    </form>

    Submit.php:

    <?php
    $fp=fopen('yourfile.txt','a');
    fwrite($fp,addslashes($usertxt));
    fclose($fp);
    header('location: index.html');
    exit();
    ?>


    You may have to change a little, but the idea is like this. Though I haven't tried it but I think this will solve your problem.
     
    shahilroyhere, Sep 18, 2008 IP
  3. Schueis

    Schueis Peon

    Messages:
    316
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That code above works nice, but the only problem is that when I hit submit, it takes me to a 404 Page, no content etc. What is the problem?
     
    Schueis, Sep 18, 2008 IP
  4. Schueis

    Schueis Peon

    Messages:
    316
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Schueis, Sep 18, 2008 IP
  5. shahilroyhere

    shahilroyhere Well-Known Member

    Messages:
    189
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #5
    You have to have a page named "submit.php". The 2nd half of the code has to be put on submit.php page.
    Now don't just put the code only there. Add the content you want to show. Something like:

    <?php
    $fp=fopen('yourfile.txt','a');
    fwrite($fp,addslashes($usertxt));
    fclose($fp);
    header('location: index.html');
    exit();
    ?>
    <html>
    <body>
    <h1>Thanks for submitting your feedback. We will get back to you soon.</h1>
    </body>
    </html

    I think this will help.
     
    shahilroyhere, Sep 18, 2008 IP