How to add email addresses from a message to a textbox?

user4385106

I'm making a webpage to send a list of email addresses to each user. I have a script called add_book.php to allow me to input a list of email addresses in the message like this:

http://oi57.tinypic.com/ra2nhw.jpg

I want to output a list of email addresses to input each of them in the textbox include with a comma when I click on the button to allow me to input the list of email addresses in the script called email.php, but I have no idea how to do this.

Like this:

http://oi60.tinypic.com/261yhl3.jpg

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Add Email Addresses...</title>
    </head>
    <body>
    <table>
        <tr>
            <td><textarea name="message" cols="50" rows="20"></textarea></td>

        </tr>
        <td colspan="2" align="left">
           <input type="submit" name="send" value="Add Email" style="height:35px; width:100px">
        </td>
    </table>
    </form>
    </body>

Here is the code for the email.php script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Send Email</title>
    <link type="text/css" rel="stylesheet" href="style.css"  />
    </head>
    <body>
    <form action="pr_send.php" method="POST">
    <table> 
        <!-- <tr>
            <td>From:</td>
            <td><input type="text" name="from"></td>
        </tr> -->
        <tr>
            <td><input type="button" name="to" value="" style="height:24px; width:24px; background:url('addressbook.png'); border:none;" onClick="Popup()"> To:</td> 
            <td><input type="text" name="to" style="height:15px; width:650px"></td> 
        </tr>
        <tr>
            <td>Subject:</td>
            <td><input type="text" name="subject" style="height:15px; width:650px"></td>
        </tr>
        <tr>
            <td>Message:</td>
            <td><textarea name="message" cols="90" rows="20"></textarea></td>
        </tr>

        <tr>
            </br>
            <td colspan="2" align="left">
               <input type="submit" name="send" value="" style="height:35px; width:100px; background:url('send.png'); border:none">
            </td>
        </tr>

    </table>
    </form>
    </body>
<script type="text/javascript">
function Popup() 
{
  window.open("add_address.php", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=500, width=400, height=400");
}
</script>

</html>

Here is the textbox that I want to output with a list of email addresses:

<td><input type="text" name="to" style="height:15px; width:650px"></td> 

Can you please help me how I can extract a list of email addresses with a comma to output them in the textbox from the script add_address.php to my script called email.php?

redreddington

Several assumptions in here and this really isn't the best way to approach things.

First you need to append the following line to the HTML in your add_address.php script just above the <table> tag:

<form action="email.php" method="post">

Without that line your form isn't going to submit anything anywhere when you click the button. The second thing to realise is that even doing this step means that your email.php page is going to open in the window you've open. Your submit, as it stands, is not going to update the email.php that you opened the window from.

That aside here's how you would then capture this.

Assuming that the data is going be email addresses on individual lines then you could do the following in email.php at the top of the page

<?php
    if (!empty($_POST['message'])) {
        $emails = explode("\n", $_POST['message']); // explode textarea on a line break into an array
        $email_str = implode(",", $emails); // take each of the emails and implode together with the ,
     }
?>

You could then refer to $email_str with an echo

<input type="text" name="to" value="<?php if (!empty($email_str)) { echo $email_str; } ?>">

That should take the content of the textarea and transpose it to a comma separated string.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How you parse a collection of email addresses with mimekit?

分類Dev

How to exclude the signature and quoted parts from email message using MimeKit?

分類Dev

How can I match email addresses in 2 dataframe

分類Dev

How to change status code & add message from failed AuthorizationHandler policy

分類Dev

Java Mail: how to show a group name as the recipient in an email instead of showing all recipient email addresses

分類Dev

How to add a title to a PHP email?

分類Dev

Importing email addresses into Active Directory

分類Dev

Thunderbird - Show all email addresses

分類Dev

Add email recipients from wc field factory for woocommerce email notification

分類Dev

retrieve a single email from imap by message_id

分類Dev

How do I do a simple forwarding to multiple email addresses in Google Apps

分類Dev

How to whilelist specific IP addresses from AWS WAF

分類Dev

How are local ip addresses separated from public ones?

分類Dev

How to copy text from one textbox to Label

分類Dev

How to access ChildWindow TextBox from MainWindow in WPF

分類Dev

How to delete filter text from textbox with buttonclick

分類Dev

What are best practices for validating email addresses in Swift?

分類Dev

iOS TestFlight - External tester email addresses

分類Dev

Send Email to Multiple Addresses in Google Spreadsheet

分類Dev

How to add RectIntl Formatted message as html attribute

分類Dev

how to add message to azure webjobs queue

分類Dev

How to auto forward to more than email from outlook email with attachments from sender when email delivered

分類Dev

how to fetch email address from oracle database

分類Dev

How to add multiple client IP addresses at time in Azure SQL Server using Azure ARM Templates?

分類Dev

How to Add dynamic image on body of Email using phpmail

分類Dev

Swift - How can I add an event listener for cancelling an email dialog?

分類Dev

How to hook into laravel built-in login to add email verified check

分類Dev

How to format a number 1000 to 1,000 for textbox to use in a Tostring in C# in a label and in a message.show

分類Dev

How to get the message content/embed from the message id?

Related 関連記事

  1. 1

    How you parse a collection of email addresses with mimekit?

  2. 2

    How to exclude the signature and quoted parts from email message using MimeKit?

  3. 3

    How can I match email addresses in 2 dataframe

  4. 4

    How to change status code & add message from failed AuthorizationHandler policy

  5. 5

    Java Mail: how to show a group name as the recipient in an email instead of showing all recipient email addresses

  6. 6

    How to add a title to a PHP email?

  7. 7

    Importing email addresses into Active Directory

  8. 8

    Thunderbird - Show all email addresses

  9. 9

    Add email recipients from wc field factory for woocommerce email notification

  10. 10

    retrieve a single email from imap by message_id

  11. 11

    How do I do a simple forwarding to multiple email addresses in Google Apps

  12. 12

    How to whilelist specific IP addresses from AWS WAF

  13. 13

    How are local ip addresses separated from public ones?

  14. 14

    How to copy text from one textbox to Label

  15. 15

    How to access ChildWindow TextBox from MainWindow in WPF

  16. 16

    How to delete filter text from textbox with buttonclick

  17. 17

    What are best practices for validating email addresses in Swift?

  18. 18

    iOS TestFlight - External tester email addresses

  19. 19

    Send Email to Multiple Addresses in Google Spreadsheet

  20. 20

    How to add RectIntl Formatted message as html attribute

  21. 21

    how to add message to azure webjobs queue

  22. 22

    How to auto forward to more than email from outlook email with attachments from sender when email delivered

  23. 23

    how to fetch email address from oracle database

  24. 24

    How to add multiple client IP addresses at time in Azure SQL Server using Azure ARM Templates?

  25. 25

    How to Add dynamic image on body of Email using phpmail

  26. 26

    Swift - How can I add an event listener for cancelling an email dialog?

  27. 27

    How to hook into laravel built-in login to add email verified check

  28. 28

    How to format a number 1000 to 1,000 for textbox to use in a Tostring in C# in a label and in a message.show

  29. 29

    How to get the message content/embed from the message id?

ホットタグ

アーカイブ