Return to Snippet

Revision: 20079
at November 6, 2009 09:37 by miebach


Initial Code
<?

ob_start();

?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="content-type" content="text/html;charset=utf-8">
</head><body>

<?
if (isset($_POST["go"])):
?>

  <h2>Thank you for sending the form!</h2>

  <? 

  global $body_for_callback;
  $body_for_callback = $_POST["name"] ." has filled in the form.";
  
  function mail_callback() {
    global $body_for_callback;
    mail("[email protected]","Form result",$body_for_callback);
  }
  register_shutdown_function(mail_callback);
else:
?>
  <form id="orderform" action="#" method="post" name="form1">
  <input type="text" name="name">
  <input type="submit" name="go" value="send form">
  </form>
<?
endif;
?>		
</body></html>
<?
header("Connection: close");
$size = ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
?>

Initial URL

                                

Initial Description
the user sees the confirmation page immedeateley. this is helpful if the mail() function takes some time

Initial Title
php form mail: send mail after display of confirmation page

Initial Tags
form, mail

Initial Language
PHP