devil_vin
02-15-2008, 09:22 AM
Hi,guys! I have a PHP script to send mail and prompt out alert if successfully sent.However,the alert is not displayed and all the form value become blank.How can I display alert without having a blank page?
Secondly,the mailing script seems having some flaws,if form submitted,the previous sent form will be sent once again into the mailbox.What went wrong actualy?Thanks for you guys help!
<?php
$email = $_GET[email];
$mailto = "yourmail@mail.com";
$mailsubj = "Enquiry sent by visitor";
$mailhead = "From: $email";
reset ($_GET);
$mailbody = "You have an enquiry from website:\n";
while (list ($key, $val) = each ($_GET)) {
if($key != 'submit')
$mailbody .= "$key : $val\n"; }
ini_set("SMTP",mail.yourmailserver.com.my);
ini_set("smtp_port",25);
ini_set("sendmail_from",$email);
$javascript = "<script type=\"text/javascript\">";
if (mail($mailto,$mailsubj,$mailbody,$mailhead)) {
$javascript .= 'alert(\'Thank you for your enquiry, we shall contact you soon.\')';
} else {
$javascript .= 'alert(\'Email cannot be delivered.\')';
}
$javascript .= '</script>';
?>
<FORM NAME="enquiry" ACTION="<?php echo htmlentities($HTTP_SERVER_VARS['PHP_SELF']); ?>" METHOD="GET">
Secondly,the mailing script seems having some flaws,if form submitted,the previous sent form will be sent once again into the mailbox.What went wrong actualy?Thanks for you guys help!
<?php
$email = $_GET[email];
$mailto = "yourmail@mail.com";
$mailsubj = "Enquiry sent by visitor";
$mailhead = "From: $email";
reset ($_GET);
$mailbody = "You have an enquiry from website:\n";
while (list ($key, $val) = each ($_GET)) {
if($key != 'submit')
$mailbody .= "$key : $val\n"; }
ini_set("SMTP",mail.yourmailserver.com.my);
ini_set("smtp_port",25);
ini_set("sendmail_from",$email);
$javascript = "<script type=\"text/javascript\">";
if (mail($mailto,$mailsubj,$mailbody,$mailhead)) {
$javascript .= 'alert(\'Thank you for your enquiry, we shall contact you soon.\')';
} else {
$javascript .= 'alert(\'Email cannot be delivered.\')';
}
$javascript .= '</script>';
?>
<FORM NAME="enquiry" ACTION="<?php echo htmlentities($HTTP_SERVER_VARS['PHP_SELF']); ?>" METHOD="GET">