TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-14-2008, 02:32 AM   #1 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default Newsletter

Hello everyone, I am trying to setup a mass mailer or in other words a news letter for my site. What is the best way to do this? Any suggestions?
KingOfTheSouth is offline  
Reply With Quote
Old 12-14-2008, 03:11 AM   #2 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

YOu have a database called e_lists

emailid, joindate, active can be your three attributes.

Then you hae a textbox + button in your php page. When people "signup" to your mailing list, you'll get their email and their joindate.

Then you can make a simple PHP script to loop through your records in your db table and email them.
masfenix is offline  
Reply With Quote
Old 12-14-2008, 01:34 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

@up- and an email field that contains the email, eh?
__________________
Tanax is offline  
Reply With Quote
Old 12-15-2008, 05:25 PM   #4 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

Well your emailid can be your email field and a primary key.
masfenix is offline  
Reply With Quote
Old 12-15-2008, 06:33 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

No. Emailid should be the ID of the email. Which would be numeric.
It's both more logical, and opens up for other possibilities.

Not saying that it's critical in THIS example of use, but generally I would say that you should always have an ID-col in every table you have in your db.
__________________
Tanax is offline  
Reply With Quote
Old 12-15-2008, 06:40 PM   #6 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

Its redundant espeically in this case.. I agree with you, a id column is needed but only when its required.

And you can figure out if you need an ID column by normalization.

I just want to point out that not every table requires an ID column. In this case an emailid (email address) field is a perfect example.

Most of my tables also use a GUID for a primary key where normalization would not lead to a two or more part primary key.
masfenix is offline  
Reply With Quote
Old 12-15-2008, 09:57 PM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

It is not redundant, not having a primary key keeps the door closed to a lot of things. Even for basic functions, the database works off of an indexed primary key much faster than a varchar value floating in a tables values.

Expansibility wise it is also a good idea. Primary keys make everything easy and fast to reference, you can also change anything else on the row without a problem.

Once again, its simply good practice to put a primary key in. Now it is not required, but being able to run does not make an application good.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-15-2008, 11:21 PM   #8 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Even for basic functions, the database works off of an indexed primary key much faster than a varchar value floating in a tables values.
True, but there's no reason why that indexed primary key absolutely must be an auto-incrementing integer type.

For the particular situation of this topic, using an email address as the PK isn't a problem unless there are plans in the future to expand the system (but we can worry about that down the line, right? right?). The email address field (PK or not) will have to be indexed (unique) anyway to save repeated entries and keep the lookups speedy (e.g. when collating the addresses to send out).

All that said, there's good reason why using an integer auto-incrementing primary key is so common and it's a healthy habit to fall into.
Salathe is offline  
Reply With Quote
Old 12-15-2008, 11:24 PM   #9 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Let's say you want to advance this project later, to have permissions and access levels. So you have a usergroup, that user with emailid 'example@no-host.com' is a member of, lets him login on your site with his email and manage some things on list as an administrator.

Then he changes his email, woopsie, you have to manually change this cause there's noone with the emailid of 'example@no-host.com'.
Thus, an emailid as a numeric, and keeping the actual email in another field, is the better solution, as I said; It will open more doors for future use.
__________________
Tanax is offline  
Reply With Quote
Old 12-16-2008, 03:53 AM   #10 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 31
Thanks: 1
masfenix is on a distinguished road
Default

Tanax I dont get that example, why would he have to do it manually? It could all be done automatically with minimal performance loss.

I can argue against that because now you have a numerical id, and therfore HAVE to make a join to the master table to make sense out of that numerical ID. And usually when I have to create a table which will reference another table then it usually done with GUID rather then int. I've found auto increment giving me a lot of problems before (espeically with duplicating, deleting etc etc)

Village Idiot, I didn't say not to have a primary key. And theres not really that much of a difference between an int and char primary key. In most cases it actually makes things easier.
masfenix is offline  
Reply With Quote
Old 12-16-2008, 11:28 AM   #11 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Because when you run a check to make someone an admin, you have:
PHP Code:
if($mysql['emailid'] == 'none@no-host.com'$_SESSION['admin'] = true
When you change his email, he won't be an admin and you have to MANUALLY change the script. Instead of just having
PHP Code:
if($mysql['emailid'] == 3$_SESSION['admin'] = true
That way you can change his email without him losing his admin-status.

This isn't really a very good example, but it's just a small one to illustrate that you SHOULD have the id as a numeric.


And if you're getting alot of problems with auto increment, sorry for this, but that doesn't mean it's _wrong_. It could mean that you just need to practice more.
__________________
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Subscribe/Unsubscribe Newsletter script Matt83 Script Giveaway 5 07-21-2010 04:06 PM
Newsletter Script Randy General 5 06-20-2008 11:31 PM


All times are GMT. The time now is 02:22 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design