Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy newsletter calling back emails from daterbase

    hi

    i am tring to to a page where the admin can send a email to all of his users.
    But first of all i am using tinymce editor (as it is the best one i know of) to design the message so the email has script has to know i am using html and i want to submit the newsletter to a table in my daterbase so i can look at pass newsletters.
    i have managed that but i am stuck with how to call all my users email adress back from the daterbase called mywigan and table called user under the coloum called email.
    now at the moment i have this
    PHP Code:

    <?php require_once('../../Connections/mywigan.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      
    $insertSQL sprintf("INSERT INTO newsletter (`from`, subject, body) VALUES (%s, %s, %s)",
                           
    GetSQLValueString($_POST['from'], "text"),
                           
    GetSQLValueString($_POST['subject'], "text"),
                           
    GetSQLValueString($_POST['body'], "text"));

      
    mysql_select_db($database_mywigan$mywigan);
      
    $Result1 mysql_query($insertSQL$mywigan) or die(mysql_error());
    }
    ?>
    <script type="text/javascript" src="../../jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
        tinyMCE.init({
            // General options
            mode : "textareas",
            theme : "advanced",
            plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",

            // Theme options
            theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
            theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
            theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
            theme_advanced_toolbar_location : "top",
            theme_advanced_toolbar_align : "left",
            theme_advanced_statusbar_location : "bottom",
            theme_advanced_resizing : true,

            // Example content CSS (should be your site CSS)
            content_css : "css/content.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url : "lists/template_list.js",
            external_link_list_url : "lists/link_list.js",
            external_image_list_url : "lists/image_list.js",
            media_external_list_url : "lists/media_list.js",

            // Style formats
            style_formats : [
                {title : 'Bold text', inline : 'b'},
                {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
                {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
                {title : 'Example 1', inline : 'span', classes : 'example1'},
                {title : 'Example 2', inline : 'span', classes : 'example2'},
                {title : 'Table styles'},
                {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
            ],

            // Replace values for the template plugin
            template_replace_values : {
                username : "Some User",
                staffid : "991234"
            }
        });
    </script>

    <form method="post" name="form1" action="<?php echo $editFormAction?>">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">From:</td>
          <td><input type="text" name="from" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Subject:</td>
          <td><input type="text" name="subject" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right" valign="top">message:</td>
          <td><textarea name="body" cols="50" rows="5"></textarea></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">&nbsp;</td>
          <td><input type="submit" value="send" onsubmit="<?php ++$send ;?>"> </td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1">
    </form>


    <p>

      <?php
      
    // multiple recipients
    if (!empty($_POST['subject'])){
    $to 'email@adress.com';   /*HELP this is where i did to get all the email from the dater base*/ 
    // subject
    $subject $_POST['subject'];

    // message
    $message $_POST['body'];

    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

    // Additional headers

    $headers .= 'From: sammottley@foo.com' "\r\n";


    // Mail it
    mail($to$subject$message$headers);
    } else {

    echo 
    '';
    };
    ?>
    </p>
    near the botom it says this :-

    $to = 'email@adress.com'; /*HELP this is where i need to get all the email from the dater base*/

    and this is the line i need help on i don't know how to call all my email adress back from the daterbase and set them under the variable of $to.

    can you help me please?

    If there is a better way of doing this or some better code that i can use please tell me

    thanks alot

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,531
    Thanks
    8
    Thanked 1,091 Times in 1,082 Posts
    How many users are there?

    Most webhosts have a limit on how many emails you can send within a given time.
    Example, you may only be able to send 100 emails every hour.

    Every host has different rules.
    Find out what your host's rules are before you spend too much time on this.

  • #3
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy

    Quote Originally Posted by mlseim View Post
    How many users are there?

    Most webhosts have a limit on how many emails you can send within a given time.
    Example, you may only be able to send 100 emails every hour.

    Every host has different rules.
    Find out what your host's rules are before you spend too much time on this.
    this website would not have a massive number of users on it i am hosted by godaddy.

    if i do have alot of uses how should i go about make a newsletter

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Might help:
    PHP Code:
    // multiple recipients
    if (!empty($_POST['subject'])) {
        
    $sQuery mysql_query('SELECT email FROM mywigan'); // Select "email" column from "mywigan" table
        
    while ($row mysql_fetch_row($sQuery)) {
        
    $to $row[0];   /*HELP this is where i did to get all the email from the dater base*/ 
        // subject
        
    $subject $_POST['subject'];

        
    // message
        
    $message $_POST['body'];

        
    // To send HTML mail, the Content-type header must be set
        
    $headers  'MIME-Version: 1.0' "\r\n";
        
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";

        
    // Additional headers

        
    $headers .= 'From: sammottley@foo.com' "\r\n";


        
    // Mail it
        
    mail($to$subject$message$headers);
        }
    }
    else {

    echo 
    '';
    }; 
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    phpcodelearner (03-14-2010)

  • #5
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    thansk you

    thanks rangana i have done it from that. sorry for the late reply i being injured from rugby and this is the first time back to my computer sorry!!

    thanks


  •  

    Posting Permissions

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