0

この form.php コードをリダイレクトする代わりに、送信後にウィンドウを閉じる簡単な方法はありますか? これを行う方法がない場合はリダイレクトに対処できますが、元のフォームが新しいウィンドウで開かれているため、ウィンドウを閉じたいだけです。以下のコード:

<?php
if (!empty($_POST)) {

// Used for later to determine result
$success = $error = false;

// Object syntax looks better and is easier to use than arrays to me
$post = new stdClass;

// Usually there would be much more validation and filtering, but this
// will work for now.
foreach ($_POST as $key => $val)
    $post->$key = trim(strip_tags($_POST[$key]));

// Check for blank fields
if (empty($post->First) OR empty($post->Last) OR empty($post->Email))
    $error = true;

else {

    // Get this directory, to include other files from
    $dir = dirname(__FILE__);


    // Get the contents of the HTML email into a variable for later
    ob_start();
    require_once($dir.'/html.php');
    $html_message = ob_get_contents();
    ob_end_clean();

    // Load the SwiftMailer files
    require_once($dir.'/swift/swift_required.php');

    $mailer = new Swift_Mailer(new Swift_MailTransport()); // Create new instance     of SwiftMailer

    $message = Swift_Message::newInstance()
                   ->setSubject('Hospitality Recycling Program Calculator Results') // Message subject
                  ->setTo(array('bsmith@cleantheworld.org', $post->Email =>$post-> First ))  // Array of people to send 

                   ->setFrom(array('bsmith@cleantheworld.org' => 'Clean the World')) // From:
                   ->setBody($html_message, 'text/html');






    // Send the email, and show user message
    if ($mailer->send($message))
        $success = true;
    else
        $error = true;

}

}
header("location: http://www.cleantheworld.org/newpartner.asp"); 
?>
4

1 に答える 1