Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts

    Adding recipients to newsletter

    Hello again,

    I'm trying to grasps some concepts of PHP. I rough coded a small newsletter system. Which you can see here http://forms.newestfunny.com/contactus.html

    What I am trying to figure out is when a person wants to be added to the recipients list, they enter their email in a form and it automatically is added to the list on contactus.html. Is there a good way to approach this? Maybe tips, ideas?

    Thanks for you help, and the read; it is much appreciated.

  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    London
    Posts
    225
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Two general ideas / questions to start with:

    1) How will all the email address be stored? Are you going to use a MySQL database? Need any pointers in how to go about that?

    2) Do you know anything about 'validating user input'? I'm referring to the idea that any data submitted by a user needs to be checked with a bit of code to make sure that you're actually receiving the type of data you expect.

    Imagine that your form says "Enter email here", and that your code saves whatever they submit without checking that it was in fact an email address that they wrote. What if they were doing something malicious, and the supposed email address was actually a script designed to hijack your site?
    So, at the very least, before saving the data, you'll want to check that what they've submitted doesn't contain any tags "<", ">" etc, and that it has a "@" in it.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    You need a database to hold all the emails. Also your page needs to be contactus.php

    Once you have the database setup, you can quickly put a query in your form to add the email.

    If you want a removal option, make another form, and when they type in their email address, have it check for that email in the database and do a query delete.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #4
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Thank you both for your replies:

    @ cfructose
    I guess I never really thought about how to store them! I don't have that much experience with MySQL but I do know the basic command lines for phpmyAdmin. I made a small test blog awhile ago and made the tables and databases for that. But nothing really fancy.
    2) I believe I can do the email check, there is plenty of examples online that will check the email. Are these the right ones for this?

    @masterofollies
    Yes, hopefully I can get the database that both of you suggested and I'll definitely put in the delete option. Great idea!

    Again thank you both and any help with the database would be awesome!
    I'll continue to experiment and see what I can pick up for the database.
    Last edited by The reaper; 03-31-2010 at 03:17 PM.

  • #5
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Did some research for the email validation, this is the easiest one I've found:
    http://www.javascriptkit.com/script/...2/acheck.shtml

    Does that work? I've never had to check before.

  • #6
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    I would be happy to help you code it, just make a database and input the following,

    Code:
    Field Name: id
    type: smallint
    value: 5
    Extra: Auto Increment
    default: (leave blank)
    
    
    Field Name: email
    type: text
    value: (Leave blank, not valid with text)
    Extra: (Leave blank)
    default: (Leave blank)
    That would be really simple structure, you could add ip address also so you can check if a person is entering a ton of different email addresses.

    One last thing, also add some type of security field, type in the words or numbers. You don't need a big script, could just be like "Type in FIRE to continue".
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • Users who have thanked masterofollies for this post:

    The reaper (04-01-2010)

  • #7
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Thanks a lot for that! I will start working on it tonight and tell you if I run into any problems. Thanks a lot, I really do appreciate it.

  • #8
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by The reaper View Post
    Yes, hopefully I can get the database that both of you suggested and I'll definitely put in the delete option. Great idea!
    Instead of deleting emails from the database I would go with a "status" column and default value of "1" for on/active, if the the user wants to opt out then the "status" is updated to "0" for off/inactive.

    1 = member receives newsletter / member in good standing
    0 = member doesn't receive newsletter / member opted out or got banned.

    Change "status" back to "1" and member is reinstated.



    -------
    Leonard Whistler

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    I don't talk to the following people. Because they are disrespectful.

    oracleguy
    Excavator
    drhowarddrfine
    MattF
    Apostropartheid
    _Aerospace_Eng_
    VIPStephan
    Fumigator
    Rowsdower!
    WA
    I am not paranoid! Which of my enemies told you that?

  • #10
    Regular Coder
    Join Date
    Oct 2009
    Location
    Florida
    Posts
    155
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Ok the to databases are made. One is "newsletter, id" second is "emaillist, email"

    So, the form action will be coded in PHP? What is the command to insert the info into the databases? And then pull them out for the checkbox newsletter form?

    thanks again, please do not spend to much time if you don't have it. I appreciate greatly what you are doing!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •