I need to show an alert box to the user in case a form gets successfully submitted.
But it is not working. The alert box does'nt pop up.
The form is on page contactus.php. I want the user to stay on that page only. So i have added
header('Location: contactus.php');
Here is the code.
PHP Code:$qry = "insert into contactus(name,email,subject,message) values('$name','$email','$subject','$message')";
$result=mysql_query($qry);
if($result)
{
echo "<script type='text/javascript'>\n";
echo "alert('Your message was successfully sent.');\n";
echo "</script>";
header('Location: contactus.php');
}
else
{
echo "<script type='text/javascript'>\n";
echo "alert('Could'nt send your message.');\n";
echo "</script>";
header('Location: contactus.php');
}


Reply With Quote
Bookmarks