Jump to content

Email Help - I want to do this better, smarter, faster!


Recommended Posts

Hi Everyone,

  So the code below works and it works fine, with one acceptation. I have to go and edit it all the time based on who joins or drops or goes on hiatus as a moderator on my little dumb site. I'd like to know if it's possible to replace ' mail("DITKO <chezshire@gmail.com>, KIRBY <scatter.heart@live.com>, GRANT <jaginfini@yahoo.com>, WHEDON <fallen_star_x5@yahoo.ca>", "[$siteName] New Player",' with something like 'mail("allmods.php", "[$siteName] New Player",...' and if that is possible, how would i write the little 'allmods.php' so that it would just insert in the e-mail addresses and I could just then edit the info in that vs. editing all the occurrences of it as i currently do.

 

 

Example of what I currently do:

if (!$APPROVED && !$id) {
mail("DITKO <chezshire@gmail.com>, KIRBY <scatter.heart@live.com>, GRANT <jaginfini@yahoo.com>, WHEDON <fallen_star_x5@yahoo.ca>", "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xpg.us/home.php", "Return-Path: Ditko <chezshire@gmail.com>\nErrors-To: Ditko <chezshire@gmail.com>\nFrom: Ditko <chezshire@gmail.com>\nReply-To: Ditko <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion());
} // end if not approved

Hello Mchl, and yes i do. I can assign mod access by a pull down menu (i inherited a site and i'm learning to do PHP to maintain the site -- it's in 4.3). I'm a newb newbie newb who will be taking some classes this winter if i can find something to match my schedule :D.

 

So yes i have a database. Is it possible to do it as a database thingie? I never imaged that as an option. Please do tell, my enquiring mind wants to know!

 

Thanks for the interest!

So I imagine, that you have a table with data like that.

 

table users
user_id, username, email, moderator
1,       DITKO,     xxx@gmail.com,   1
2,       other_user, xxx@mail.net,   0

 

Do you know how to query database from php?

If, not there's an example in the manual

I have a database for users called login which has:

ipLDB, id, username, password, name, email, emailprivate, dob, web, city, state, country, comments, sampleLDB, fcRequestLDB, lastmodified, dateadded, lastlogin, lastvisit, moderator, approved, moderated, yahoo, aim, icq, prefs.

 

 

 

Thank you Mchl,

 

I hope i'm understanding you correctly, I believe that below is how you are suggesting i can simplify the code and my life by using the 'SELECT username, email FROM login WHERE moderator IN ('true','super')' line to replace all the mod addresses which i have to continually replace with an action that pulls the addresses of whoever is a moderator.

 

Is that correct and is the execution below correct? (Huge thanks for opening my eyes to a completely new way of looking at PHP)

 

if (!$APPROVED && !$id) {

mail("SELECT username, email FROM login WHERE moderator IN ('true','super')", "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xpg.us/home.php", "Return-Path: Ditko <chezshire@gmail.com>\nErrors-To: Ditko <chezshire@gmail.com>\nFrom: Ditko <chezshire@gmail.com>\nReply-To: Ditko <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion());

} // end if not approved

Erm... not really...

 

You have to connect to database first, perform a query, then form a string with moderators' adresses and use it in mail function.

 

See this example on how working with database looks

Thanks -- So i look at the reference and I've come up with this, I think i understand the general concept now, but i don't know that i'm writing the instruction correctly. (i'm a dweeb):

if (!$APPROVED && !$id) {
mail(;
$query = "SELECT username, email FROM login WHERE moderator IN ('true','super')";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
{
"[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xpg.us/home.php", "Return-Path: Ditko <chezshire@gmail.com>\nErrors-To: Ditko <chezshire@gmail.com>\nFrom: Ditko <chezshire@gmail.com>\nReply-To: Ditko <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion());
} // end if not approved

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.