943,753 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 305
  • PHP RSS
Jul 13th, 2009
0

Email form

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
NoID is offline Offline
49 posts
since Jul 2009
Jul 13th, 2009
0

Re: Email form

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.

php Syntax (Toggle Plain Text)
  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>
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008
Jul 13th, 2009
0

Re: Email form

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
Reputation Points: 10
Solved Threads: 0
Light Poster
NoID is offline Offline
49 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: [php]executing 'pict'
Next Thread in PHP Forum Timeline: How we can fetch value on same page in PHP???





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC