Email form

Reply

Join Date: Jul 2009
Posts: 39
Reputation: NoID is an unknown quantity at this point 
Solved Threads: 0
NoID NoID is offline Offline
Light Poster

Email form

 
0
  #1
Jul 13th, 2009
Hello Guys,

I am not really sure how to ask this, but i will try my best, as much help will be apericiated.

I have a saved.php page which echos all saved data that i have filled inluding customer email. I then want a email.php to have echoing all emails stored, but i want a check box which when i tick and press submit sends a mass email to all users that i have checked.

Can someone please point me to the right direction or give a tutorial which shows similar to what i want.



Thank you
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 94
Reputation: sikka_varun is an unknown quantity at this point 
Solved Threads: 11
sikka_varun's Avatar
sikka_varun sikka_varun is offline Offline
Junior Poster in Training

Re: Email form

 
0
  #2
Jul 13th, 2009
Hi,

I hope you know how to send a mail to a user in php. If you know this, then the below code can help you.

Basic idea: Show a checkbox in front of every email id. Select and click a submit button to send emails to the selected email ids.

  1. <?
  2. if($_POST['submit'] == "Send Mass Mail")
  3. {
  4. // When someone presses submit button given below
  5.  
  6. if(count($_POST['email_ids']) >0)
  7. {
  8. foreach($_POST['email_ids'] as $key)
  9. {
  10. //mail function - (to_field, subject_field,msg_field,headers)
  11. // Set it accordingly
  12. $subject = "Your mailer subject";
  13. $to = $key;
  14. $msg = "Here is our product";
  15. mail($to,$subject,$msg,$header);
  16. }
  17. }
  18. }
  19.  
  20. ?>
  21.  
  22. // This is the form that shows all the emails and the checkboxes
  23.  
  24. <form name="emailfrm" method="post" action="">
  25. <table border="0" cellpadding="2" cellspacing="1">
  26. <thead>
  27. <tr>
  28. <th>Email Id</th>
  29. <th>&nbsp;</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <?php
  34. $res = mysql_query("Select email from <tablename>");
  35. while($data = mysql_fetch_array($res))
  36. {
  37. // Show all the emails from the database. Choose the tablename above
  38. ?>
  39. <tr>
  40. <td><?php echo $data['email']; ?></td>
  41. <td><input type="checkbox" name="email_ids" id="email_ids" value="<?php echo $data['email']; ?>" /></td>
  42. </tr>
  43. <?php
  44. }
  45. ?>
  46. <tr>
  47. <td colspan="2"><input type="submit" name="submit" id="submit" value="Send Mass Mail" />
  48. </tr>
  49. </tbody>
  50. </table>
  51. </form>
VâRûN
---Happy to Help---
sikka_varun@yahoo.com
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 39
Reputation: NoID is an unknown quantity at this point 
Solved Threads: 0
NoID NoID is offline Offline
Light Poster

Re: Email form

 
0
  #3
Jul 13th, 2009
Thank you for that reply, i slightly understand what you are doing, but just tad hard for me to implement it to my form, as i am still learning lol. It is much apericiated for you taking your time in doing the code for me,

I have just thought if i can do it this way, where i have a text box which when i type the ID of that customer and press submit, it goes to MYSQL database gets the email and sends it.

Please note i have a datbase which gives id to every customer and has a section for email which is "EmailAD"

Thank you
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC