Jump to content

pcw

Members
  • Posts

    285
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pcw's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Thanks Pikachu2000, with that and changing id to name in the form it works :-)
  2. Ok made a few changes now, but keep getting errors to say there is an unextpected { on line 29 and the 30 but I cant seem to work out where to put them. <?php include_once("../../data/server.php"); include("../../data/mysql.php"); $sendTo = $_POST['sendTo']; if ($sendTo == "All Members") { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['email']; $to = "$emailaddress"; $subject = "$subject"; $body = "$message"; $headers = "From: $adminEmail\r\n" . "X-Mailer: php"; mail($to, $subject, $body, $headers) } } elseif ($sendTo == "Approved Members") { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members WHERE approved='yes'"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['email']; $to = "$emailaddress"; $subject = "$subject"; $body = "$message"; $headers = "From: $adminEmail\r\n" . "X-Mailer: php"; mail($to, $subject, $body, $headers) } mysql_close($con); } ?> Help please
  3. Doesnt this already do that? $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress'];
  4. Hi guys, Thanks for your replies. I have made a few changes, such as the select field in the message form instead of radio fields, but I am having some problems getting it to work. I have changed users to members as that is the name of the table in my database. So here is what I have got: Form <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=database&username=admin">Database</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=editTemplate&username=admin">Templates </a> <a href="admin.php?cmd=email&username=admin">Email</a> <a href="admin.php?cmd=messaging&username=admin">Messaging</a> <a href="admin.php?cmd=protected&username=admin">Protected Directory</a> <a href="admin.php?cmd=filesanddir&username=admin">Files and Directories</a> <a href="admin.php?cmd=usertracking&username=admin">User Tracking</a> <a href="admin.php?cmd=advanced&username=admin">Advanced</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=subscriptions&username=admin">Subscriptions</a> <a href="admin.php?cmd=applications&username=admin">Applications</a> <a href="admin.php?cmd=searchForms&username=admin">Search Form Builder</a> <a href="admin.php?cmd=categories&username=admin">Categories</a> <a href="admin.php?cmd=phpBB&username=admin">phpBB</a> <a href="admin.php?cmd=mySQL&username=admin">MySQL</a></div> </div> <div id="content"> <div class="page"> <form action=templates/admin/msgtest.php method=POST> <table> <tr> <td>Your Message:</td> <tr><td> </td><td> </td></tr> <tr><td>Subject:</td><td> <input type="text" id="subject"></td></tr> <tr><td>Message</td><td>Message:<textarea id="message"></textarea></td></tr> <tr><td>Send to:</td><td><select name=sendTo> <option></option> <option>All Members</option> <option>Approved Members</option> </select> <tr><td colspan=2><input type=submit name=submit value=Submit></td></tr> </table> </form> </table> </div> </div> </div> Script <?php include_once("../../data/server.php"); include("../../data/mysql.php"); $sendTo = $_POST['sendTo']; if ($sendTo == 'All Members') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress']; mail($emailaddress,"$subject","$message","From:$adminEmail"); } mysql_close($con); } elseif ($sendTo == 'Approved Members') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $subject = $_POST['subject']; $message = $_POST['message']; $getusers = mysql_query("SELECT email FROM members WHERE approved='yes'"); while($result = mysql_fetch_array($getusers)) { $emailaddress = $result['emailaddress']; mail($emailaddress,"$subject","$message","From:$adminEmail"); } } mysql_close($con); ?> Thanks for your help
  5. Hi, I got this script which I would like to send a message to all email addresses in the database or send to approved members only. Once I got the first part of this script working I can get the rest to work when sending to approved members. Here is the form which passes the message to the script. <?php include_once("data/server.php"); $all = 'unchecked'; $approved = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $all = 'checked'; } else if ($selected_radio == 'approved') { $approved = 'checked'; } } ?> <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=database&username=admin">Database</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=editTemplate&username=admin">Templates </a> <a href="admin.php?cmd=email&username=admin">Email</a> <a href="admin.php?cmd=messaging&username=admin">Messaging</a> <a href="admin.php?cmd=protected&username=admin">Protected Directory</a> <a href="admin.php?cmd=filesanddir&username=admin">Files and Directories</a> <a href="admin.php?cmd=usertracking&username=admin">User Tracking</a> <a href="admin.php?cmd=advanced&username=admin">Advanced</a> <a href="admin.php?cmd=uploads&username=admin">Uploads</a> <a href="admin.php?cmd=subscriptions&username=admin">Subscriptions</a> <a href="admin.php?cmd=applications&username=admin">Applications</a> <a href="admin.php?cmd=searchForms&username=admin">Search Form Builder</a> <a href="admin.php?cmd=categories&username=admin">Categories</a> <a href="admin.php?cmd=phpBB&username=admin">phpBB</a> <a href="admin.php?cmd=mySQL&username=admin">MySQL</a></div> </div> <div id="content"> <div class="page"> <form action=templates/admin/msgtest.php method=POST> <table> <tr> <td>Your Message:</td> <tr><td> </td><td> </td></tr> <tr><td><TEXTAREA NAME="message" COLS=40 ROWS=6></TEXTAREA></td></tr> </table> <table> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $all; ?> </td> <td>Send Message to all members</td> </tr> <tr> <td><input type = 'Radio' Name ='Mailto' value= 'yes' <?PHP print $approved; ?> </td> <td>Send Message to Approved members only</td> </tr> <tr><td colspan=2><input type=submit name=submit value=Submit></td></tr> </table> </form> </table> </div> </div> </div> And here is the code I have got so far but it doesnt work <?php include_once("../../data/server.php"); include("../../data/mysql.php"); if (isset($_POST['Submit1'])) { $selected_radio = $_POST['Mailto']; if ($selected_radio == 'all') { $mysqlPassword = (base64_decode($mysqlpword)); $con = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die(mysql_error()); mysql_select_db("$dbname", $con) or die(mysql_error()); $q2 = "select * from games_newsletter "; $result = mysql_query("SELECT email FROM profiles"); while ($email = mysql_fetch_assoc($result)) { $to = $email; $subject = "Test Message"; $body = "This is a test message"; $headers = "From: payments@tropicsbay.co.uk\r\n" . "X-Mailer: php"; if (mail($to, $subject, $body, $headers)) { // Redirect back to manage page header("Location: admin.php?cmd=messaging"); } else { echo "Approval Message Failed"; } } mysql_close($con); } } ?> As always, any help is much appreciated Paul
×
×
  • 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.