Hi,guys! I have a script to sending mail from form and display alert message after sent.I am having problem on displaying the alert message even if mail is already sent and also data in field being reset.
How to display the alert message without reset the field data in the same page?
<?php
if(isset($_GET["submit"]))
{
$email = $_GET[email];
$mailto = "vincent@seenergy.com.my";
$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.seenergy.com.my);
ini_set("smtp_port",25);
ini_set("sendmail_from",$email);
$javascript = "";
$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>";
}
?>
<BODY onload =<?php echo $javascript; ?>>
<FORM NAME="enquiry" ACTION="<?php echo htmlentities($HTTP_SERVER_VARS['PHP_SELF']); ?>" METHOD="GET">