Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 2.21 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.         require_once('includes/realm1.php')
  3. ?>
  4.  
  5. <!DOCTYPE html
  6.         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  7.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  8. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  9.         <head>
  10.         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  11.                 <title>Newsletter</title>
  12.                 <link type="text/css" rel="stylesheet" href="black.css" />
  13.         </head>
  14.        
  15.         <body>
  16.                 <?php
  17.                 include 'includes/settings.php';
  18.                 include 'includes/header.php';
  19.                 include 'includes/leftsidebar.php';
  20.                 include 'includes/extraleftsidebar.php';
  21.                 ?>
  22.                 <div id="main">
  23.                 <h1 class="centered">Newsletter Directory</h1>
  24.                 <p></p>
  25.                 <?php
  26.                 if(isset($_POST['submit'])){
  27.                 $from='henry@condeso.net';
  28.                 $subject=$_POST['subject'];
  29.                 $text=$_POST['text'];
  30.                 $output_form=false;
  31.                 if (empty($subject) && empty($text)){
  32.                 echo 'You forgot the email subject and message.<br />';
  33.                 $output_form=true;}
  34.                 if (empty($subject) && (!empty($text))){
  35.                 echo 'You forgot the email subject.<br />';
  36.                 $output_form=true;}
  37.                 if ((!empty($subject)) && empty($text)){
  38.                 echo 'You forgot the email message.<br />';
  39.                 $output_form=true;}
  40.                 if ((!empty($subject)) && (!empty($text))){
  41.                 $dbc=mysqli_connect('localhost', 'User', 'Password', 'Database')
  42.                         or die('Error connecting to MySQL server.');
  43.                 $query="SELECT * FROM users";
  44.                 $result=mysqli_query($dbc, $query)
  45.                         or die('Error querying database.');
  46.                 while($row=mysqli_fetch_array($result)){
  47.                 $firstname=$row['firstname'];
  48.                 $lastname=$row['lastname'];
  49.                 $message="Dear $firstname $lastname,\n$text";
  50.                 $to=$row['email'];
  51.                 mail($to, $subject, $message, 'From:'.$from);
  52.                 echo 'Email sent to : '.$to.'<br />';}
  53.                 mysqli_close($dbc);}}
  54.                 else{$output_form=true;}
  55.                 if ($output_form){
  56.                 ?>
  57.                 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  58.                         Subject : <input type="text" value="<?php echo $subject; ?>" name="subject" /><br />
  59.                         Message : <textarea rows="8" cols="40" name="text"><?php echo $text; ?></textarea><br />
  60.                         <input type="submit" value="Send mass email" name="submit" />
  61.                 </form>
  62.                 </div>
  63.                
  64.                 <?php
  65.                 }
  66.                 include 'includes/extramain.php';
  67.                 include 'includes/analytics.php';
  68.                 ?>
  69.         </body>
  70. </html>