SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am making a simple mailing list script.

    I have a table in 1 database called "newsletter", with a column called "email" which contains the newsletter sign ups. I also have a table in another database called "user" with a column also called "email" with the users email addresses from my forums.

    Now, I have a question :

    How would I go about in the sign up process of checking BOTH databases to check if the email address already exists, then displaying the appropriate message?

    Thanks
    James.

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It would make more sense to combine your two tables into one, with columns to indicate whether a particular user is a newsletter subscriber, a forum user, or both.

    Better yet, unify the sign-up process so that anyone who signs up to your newsletter becomes a forum user and vice versa.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I can't really make anyone who signs up to the mailing list a forum member, because the only info they input is their address. However, what I'm trying to do is as you said, also email the newsletter to all of my forum members.

    I cannot store all of the sign ups from the newsletter form in the forum table, as this table contains info like "user name", "no. of posts" etc etc.

    How should I solve this ?

    Thanks
    James

  4. #4
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could create your newsletter table(s) in the forum database.

    The forum script won't even know that the new table(s) are there...
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  5. #5
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i realised that, but my orignial question is stil unanswered....

    how can i check if someone is on EITHER of the lists ?

    What im saying is i dont want forum members to be able to sign up to the newsletter email list cos it will be going out to them twice if they do

    j

  6. #6
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, well.. if you insist on having two databases then your script will have to:

    1)Take the email address from the user after submission and store it into a $email variable.

    2)Log into the *other* database, and do a SELECT * from database_name WHERE email=$email. If the query returns a row, then you already have the email in the other database.
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  7. #7
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well I can't really make anyone who signs up to the mailing list a forum member, because the only info they input is their address.
    Correct me if I'm wrong, but you want forum members, right? Also feel free to tell me I'm off my rocker, but newsletter subscribers are a good thing, right?

    So why wouldn't unifying the signup process for these two services be a good thing? The way I see it, you'll get a) more forum members, b) more newsletter subscribers, and c) a more efficient database design. What's wrong with that?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  8. #8
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as sitepoint has, a "newsletter sign up" box on every page, i am gonna have one as well.

    to sign up for the forums, info such as username, password, blah blah blah is needed. all i want for the user to have to input to sign up for the Mailing list is their email address.

    j

  9. #9
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Okay, okay, I give up.

    Try something like this:

    SELECT count(*) FROM newsletter, forums WHERE newsletter.email = '$email' OR forums.email = '$email'

    If the above query returns anything other than zero, then the person is already registered.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  10. #10
    psycho
    Join Date
    May 2000
    Location
    London
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your help.

    how would i test the result of this query ?

    $result = SELECT count(*) FROM newsletter, user WHERE newsletter.mail = '$email' OR user.email = '$email'

    is wrong

    thanks
    j

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $result = SELECT count(*) FROM newsletter, user WHERE newsletter.mail = '$email' OR user.email = '$email'

    if (mysql_num_rows($result) > 0) {
    do something
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  12. #12
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    First, don't forget the quotes around your query. Second, this query will always return one row. It's the value that's returned that matters.

    Code:
    $result = "SELECT count(*) FROM newsletter, user ".
    "WHERE newsletter.mail = '$email' OR user.email = '$email'";
    
    if (mysql_result($result,0,0) > 0) { 
    do something 
    }

    <Edited by kyank on 01-24-2001 at 06:04 PM>
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and the mysql_query() function

    $result = mysql_query("SELECT count(*) FROM newsletter, user WHERE newsletter.mail = '$email' OR user.email = '$email'");

    if (mysql_result($result,0,0) > 0) {
    do something
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  14. #14
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Wow, are we brain dead today or what??
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

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