Hi guys,
I have a form in which the user types its email. The email is then inserted in a mysql db using a php file.
[B]Form code:
<form name=”frm” method=”post” action=”newsletter.php” onSubmit=”return ValidateForm()”>
<input type=”text” name=”email”>
<br/>
<input type=”submit” name=”Submit” value=”Enviar”>
</form>
[B]
PHP file code:
<?php
$con = mysql_connect(“localhost”,”user”,”pass”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“db”, $con);
$sql=”INSERT INTO newsletter (email)
VALUES
(‘$_POST[email]’)”;
if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “Thank you”;
mysql_close($con)
?>
Fortunetly everything is working fine with regards to the db connection, but the browser is directed to the php file and shows the echo “Thank you”;
Want I need to do is rather than being redirected to the php file, just to show something like an alert (e.g. “Your email has been added to our mailing list”) and stay in the same html page where the form is.
Is this doable? And how?
Many thanks
Fred