Hi guys,

I need your help, I want to close a page when a button is pressed. I'm using the script add_address.php to output a list of email addresses from the message box and I want to output the email addresses to the text box in the send.php script

Here is the code for add_address.php:

<!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>
    <form action="send.php" method="post">
    <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 send.php:

<?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 ,
     }
?>

<!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" value="<?php if (!empty($email_str)) { echo $email_str; } ?>" 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>
            <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>

What my snippets have show, it will only allowed me to output the list of email addresses in the message box and it will redirect to the send.php page to output the list of email addresses in the text box without close it.

function closeWin() {
    myWindow.close();   // edit myWindow to your window name
}
commented: This is what they needed. +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.