Services_Mailman
[ class tree: Services_Mailman ] [ index: Services_Mailman ] [ all elements ]

Source for file mailman-newsletter.php

Documentation is available at mailman-newsletter.php

  1. <?php
  2.  
  3. //Settings
  4. $notice='';
  5. $_mmurl='http://example.co.uk/mailman/admin';
  6. $_mmlist='newsletter_example.co.uk';
  7. $_mmpw='password-cannot-have-spaces';
  8. $_mmsub='Yey! Thanks for joining our newsletter.';
  9. $_mmunsub='Sorry to see you go :(';
  10. $_mmerror='There was some kind of error, check and try again.';
  11.  
  12. //Logic
  13.     if ($_POST{
  14.         $_email=filter_var($_POST['email']FILTER_VALIDATE_EMAIL);
  15.         if ($_email{
  16.             require 'Services/Mailman.php';
  17.             $mm=new Services_Mailman($_mmurl,$_mmlist,$_mmpw);
  18.             $notice $_mmsub;
  19.             if ($_POST['sub'== 1{
  20.                 try {
  21.                     $mm->subscribe($_email);
  22.                 catch (Services_Mailman_Exception $e{
  23.                     $notice $_mmerror;
  24.                 }
  25.             }
  26.             elseif ($_POST['sub'== 0{
  27.                 try {
  28.                     $mm->unsubscribe($_email);
  29.                 catch (Services_Mailman_Exception $e{
  30.                     $notice $_mmerror;
  31.                 }
  32.             }
  33.         else {
  34.             $notice=$_mmerror;
  35.         }
  36.     }
  37.     unset($_mmpw);
  38.  
  39. //Markup
  40. ?>
  41. <h2>Newsletter</h2>
  42. <?php if ($notice{?><div class="notice"><?=$notice?></div><?php ?>
  43. <form method="post" id="newsletter_form" action="">
  44.     <div>
  45.         <label for="input_email">Email address:</label>
  46.         <input type="text" name="email" id="input_email">
  47.     </div>
  48.     <div>
  49.         <input type="radio" id="input_sub" name="sub" value="1" checked>
  50.         <label for="input_sub">Subscribe</label>
  51.         <br>
  52.         <input type="radio" id="input_unsub" name="sub" value="0">
  53.         <label for="input_unsub">Unsubscribe</label>
  54.     </div>
  55.     <input type="submit" value="Submit &raquo;" id="submit">
  56. </form>

Documentation generated on Mon, 11 Mar 2019 15:47:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.