1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Subscribe to my Newsletter

Discussion in 'PHP' started by bengaluru, Jun 9, 2008.

  1. #1
    Hi

    Can somebody provide me a code to create a Subscribe to My Newsletter form.

    What I want is just a field where the user enters his email ID and click on the "subscribe" button. Once submitted he gets a thank you message either to his email address or instantly on the screen. And I should receive an email with the emailaddress of the subscriber.

    Thank you for your assistance.
     
    bengaluru, Jun 9, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    If you would like to pay for it, send me a PM with all your details including design and i'll create it for you!
     
    EricBruggema, Jun 10, 2008 IP
  3. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If I had to pay why would I post in this forum? See this reply on one of the earlier threads where someone offered to help.

     
    bengaluru, Jun 10, 2008 IP
  4. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Google for "free mailing list manager PHP scripts". There are many available. If you didn't do your homework properly, it was not unexpected if somebody offered paid help.:)
     
    rohan_shenoy, Jun 10, 2008 IP
  5. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The form is easy... the rest might be a bit harder though. If you already have some sort of software that will send out emails, you can just set up something like this:

    <?php
    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'];

    mail( "youremailhere@yourdomain.com", "Subject: add $email", "$name $email", "From: $email" );

    ?>

    <form action="" method="POST">
    Name: <input name="name">
    Email: <input name="email">
    <input type="submit">
    </form>
     
    coffeesonnow, Jun 10, 2008 IP
  6. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you so much Coffeesonnow. This is the kind of response I was looking for and not the other ones. If people do not want to help or looking for money, then they should go elsewhere. And for Rohan, why do you assume that I would not have done my homework. Just dont respond if you do not want to help.....it's just that easy.

     
    bengaluru, Jun 10, 2008 IP
  7. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sure thing :) Hope it works well.
     
    coffeesonnow, Jun 10, 2008 IP
  8. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It does work. But this is not what I was looking for. I do not want the subscriber to send an email, instead I want them to just enter their email in the text box and click on subscribe. It should then generate a "Thank You" and I should have the email stored in a file in my server.

    So If you can please provide me the code (front end - the form with just one text box and subscribe button) and all the other php codes, I would greatly appreciate that. I did look at several websites googling, but was not able to do it. Hence I came to this forum. Thanks for your help.
     
    bengaluru, Jun 11, 2008 IP
  9. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ok, it would depend on what software you're using... you just want it in a list in a file?
     
    coffeesonnow, Jun 11, 2008 IP
  10. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Yes my friend. I will create a text file called "email.txt" and all I need is the email ID's get stored there. Is this too much of a work for you ? sorry for the trouble and thank you so much for the help.:D
     
    bengaluru, Jun 11, 2008 IP
  11. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ok, this should work then :)

    <?php
    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'];

    $emails = fopen("emails.txt","a");
    fwrite($emails, $name." | ".$email."\n");
    fclose($emails);


    ?>

    <form action="" method="POST">
    Name: <input name="name">
    Email: <input name="email">
    <input type="submit">
    </form>
     
    coffeesonnow, Jun 11, 2008 IP
  12. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Thanks a lot Coffeesonnow. Your help is much appreciated.

    Question: How does it get stored in the emails.txt. I downloaded the emails.txt from the server but did not find any email addresses there that I had tested. ? Also I have changed the permissions to emails.txt to full permission (CHMOD 777)

    And how can I add a "Thank you. Your email has been added to our Mailing list" appear on the screen.

    Take care
     
    bengaluru, Jun 12, 2008 IP
  13. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Ok, so when you used the form it didn't store the email?

    As for the message, just add

    if(isset($name)) {
    echo "Thank You ".$name.". Your email has been added to our mailing list.";
    }


    in between the <?php ?> tags somewhere.
     
    coffeesonnow, Jun 12, 2008 IP
  14. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Yes it did not store. How do we fix this ?
     
    bengaluru, Jun 12, 2008 IP
  15. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Hmm... It's working on my server. Nothing at all is getting placed in the file?
     
    coffeesonnow, Jun 12, 2008 IP
  16. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I dont know what I might have done wrong.......but it is not working. Even the thank you message does not come up.
     
    bengaluru, Jun 12, 2008 IP
  17. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #17
    ok set the form action= to the name of the php file.
     
    coffeesonnow, Jun 12, 2008 IP
  18. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    What php file? Am I supposed the place the above code in a file and then use the file name for form action. sorry my friend, I dont understand. php is alien to me....you got to walk me every step.
     
    bengaluru, Jun 12, 2008 IP
  19. coffeesonnow

    coffeesonnow Peon

    Messages:
    34
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #19
    <?php
    // File Name
    $filename = "filename.php";

    //Name
    $name = $_REQUEST['name'];
    //Email
    $email = $_REQUEST['email'];

    //Write To File
    $emails = fopen("emails.txt","a");
    fwrite($emails, $name." | ".$email."\n");
    fclose($emails);

    // If They've Filled Out The Form
    if(isset($name)) {
    // Tell them this.
    echo "Thank You ".$name.". Your email has been added to our mailing list.";
    }


    ?>

    <form action="<? echo $filename; ?>" method="POST">
    Name: <input name="name">
    Email: <input name="email">
    <input type="submit">
    </form>

    Put the above code in a php file, then in that top field where it says "filename.php" put the name of the file you've put the code in :)
     
    coffeesonnow, Jun 13, 2008 IP
  20. bengaluru

    bengaluru Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Thank you so much my friend. But it does not work. See my next post.

    I thought you got tired of my questions and was not coming back.
     
    bengaluru, Jun 13, 2008 IP