Chezshire Posted September 12, 2008 Share Posted September 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/ Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 First: No need to show us their email addresses. Second: Do you have a database where you store data about your users and moderators? Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639541 Share on other sites More sharing options...
Chezshire Posted September 12, 2008 Author Share Posted September 12, 2008 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 . 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! Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639545 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639550 Share on other sites More sharing options...
Chezshire Posted September 12, 2008 Author Share Posted September 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639561 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 So you'll need query like this: SELECT username, email FROM login WHERE moderator = 1 If moderators are described by '1' in 'moderator' column. Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639566 Share on other sites More sharing options...
Chezshire Posted September 12, 2008 Author Share Posted September 12, 2008 I use 'enum('', 'true', 'super')' so would it be something more like SELECT username, email FROM login WHERE moderator = true OR super; ? Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639576 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 WHERE moderator IN ('true','super') Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-639579 Share on other sites More sharing options...
Chezshire Posted September 12, 2008 Author Share Posted September 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-640102 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-640109 Share on other sites More sharing options...
Chezshire Posted September 12, 2008 Author Share Posted September 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/123868-email-help-i-want-to-do-this-better-smarter-faster/#findComment-640151 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.