login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Ledensystemen > nieuwsbrief

nieuwsbrief

Auteur: pj_muller00 - 08 oktober 2006 - 16:15 - Gekeurd door: Wijnand - Hits: 52270 - Aantal punten: 2.38 (4 stemmen)




Na dat iemand vroeg in samenwerken om voor hem een nieuwsbrief script te schrijven heb ik dat maar even gedaan.

En dan kan ik het even goed ook via deze weg aan anderen geven ...

Code:
config pagina :

  1. <?php
  2. $tabel = 'tabel';
  3. $header = "From: Yourname <info@yourname.com>";
  4. ?>


insert pagina ...
  1. <?php
  2. include_once('config.php');
  3.  
  4. if(isset($_POST['insert'])){
  5. $query = "INSERT INTO ".$tabel." (email) VALUES ('".$_POST['email']."')";
  6. mysql_query($query);
  7. echo $_POST['email']." inserted<br>";
  8. }
  9. else{
  10. ?>
  11. <form method="post">
  12. <table>
  13. <tr>
  14. <td>New email-adres</td>
  15. <td><input type="text" name="email" size="25" maxlength=45></td>
  16. <td><input type="submit" name="insert" value="Insert !"></td>
  17. </tr>
  18. </table>
  19. </form>
  20. <?php
  21. }
  22. ?>


Admin kant deleten, verwijderen:
  1. <?php
  2. include_once('config.php');
  3.  
  4. if(isset($_POST['delete'])){
  5. $query = "SELECT id,email FROM $table";
  6. $result = mysql_query($query);
  7. while($row = mysql_fetch_array($result)){
  8. if(isset($_POST['email'.$row['id']])){
  9. $query = "DELETE FROM $table WHERE id = ".$row['id'];
  10. mysql_query($query);
  11. echo $row['email']." deleted<br>";
  12. }
  13. }
  14. }
  15. else{
  16. ?>
  17. <form method="post">
  18. <table>
  19. <?php
  20. $query = "SELECT id,email FROM $table";
  21. $result = mysql_query($query);
  22. while($row = mysql_fetch_array($result){
  23. echo "
  24. <tr>
  25. <td>".$row['email']."</td>
  26. <td><input type='checkbox' name='email".$row['id']."'></td>
  27. </tr>";
  28. }
  29. ?>
  30. </table>
  31. <input type="submit" name="delete" value="Delete">
  32. </form>
  33. <?php
  34. }
  35. ?>


Mail versturen :
  1. <?php
  2. include_once('config.php');
  3.  
  4. if(isset($_POST['send'])){
  5. echo "<h2>Send</h2><br>";
  6.  
  7. $title = stripslashes($_POST['title']);
  8. $message = stripslashes($_POST['message']);
  9.  
  10. echo "<b>".$title."</b><br>";
  11. echo nl2br($message)."<br>";
  12.  
  13.  
  14. $query = "SELECT distinct email FROM ".$table;
  15. $result = mysql_query($query);
  16. while($row = mysql_fetch_array($resultaat)){
  17.  
  18. $email = mail($row['email'],$title,$message,$header);
  19.  
  20. if($email == 1){
  21. echo "Mail sended ".$row['email']."<br>\n";
  22. }
  23. elseif($email == 0){
  24. echo "Not sended to".$row['email']." <br>\n";
  25. }
  26. }
  27. }
  28. elseif(isset($_POST['example'])){
  29. echo "<h2>Example</h2><br>";
  30.  
  31. $title = stripslashes($_POST['title']);
  32. $message = stripslashes($_POST['message']);
  33.  
  34. echo "<b>".$title."</b><br>";
  35. echo nl2br($message)."<br>";
  36. ?>
  37. <form method="post">
  38. <input type="hidden" name="message" value=<?= $message; ?>">
  39. <input type="hidden" name="title" value="<?= $title; ?>">
  40. <input type="submit" name="send" value="Send ">
  41. </form>
  42. <?php
  43. }
  44. else{
  45. echo "<h2>Mailing</h2><br>";
  46. ?>
  47. <form method="post">
  48. Title : <input type="text" name="title" size=50><br>
  49. Message : <br><textarea name="message" cols=50 rows=4 wrap=virtual></textarea><br><br>
  50. <input type="submit" name="example" value="Show example">
  51. </form>
  52. <?php
  53. }
  54. ?>
Download code! Download code (.txt)

 Stemmen
Niet ingelogd.

 Reacties
Post een reactie
Lees de reacties (16)
© 2002-2023 Sitemasters.be - Regels - Laadtijd: 0.051s