News mailing list

Posted on Wednesday 8th August 2007 at 10:16 PM
dtnet
dtnet's Avatar
A friend of mine need a news mailing list-sript that does this:

E.g.

I'm writing my e-mail adress in a form and press submit, and then the administrator gets my e-mail adress, so he can add me to a news mailing list.


Sorry for my bad language, but didn't know the english word for what I ment ;)
Posted on Wednesday 8th August 2007 at 11:16 PM
Diablosblizz
Diablosblizz's Avatar
Haha, simple.

PHP Code
  1. <?php
  2. switch ($_GET[page]) {
  3.  
  4. default:
  5. echo "<form action='?page=mail' method='post'>
  6. Your email address: <input type='text' name='email'><BR>
  7. <input type='submit' value='Submit'>
  8. </form>";
  9. break;
  10.  
  11. case 'mail':
  12.  
  13. $email = $_POST[email];
  14.  
  15. if(!$email) {
  16. echo "You need to enter in your email address!";
  17. } else {
  18.  
  19. $subject = "Message from a user.";
  20. $from = "$email";
  21. $body = "$email would like you to add them to the mailing list!";
  22. $to = "YOUREMAILADDRESSHERE@DOMAIN.COM";
  23.  
  24. mail($to, $subject, $body, "From: $email");
  25.  
  26. if(mail) {
  27. echo "Message sent.";
  28. } else {
  29. Echo "Error, please try again.";
  30. }
  31. break;
  32. }
  33. ?>


Should work, if it doesn't then tell me and I'll attempt to fix.
Posted on Saturday 11th August 2007 at 10:36 PM
dtnet
dtnet's Avatar
Didn't work. I think he didn't got any e-mail.
Login or register to respond to this forum topic.