Hi--
I was hoping someone could tell me how to edit this contact form so that it does not redirect to another page (the php page)? I'd like it to just simply send the message without leaving the page. The trick here is that I am using a javascript link to submit the form, NOT a button...
Any help would be most appreciated!
HTML PAGE:
<body>
<script type="text/javascript">
function submitform()
{
document.forms["form"].submit();
}
</script>
<form id= "form" method="POST" name="form" action="mailer.php">
Name:
<input type="text" name="name" size="19"><br>
<br>
E-Mail:
<input type="text" name="email" size="19"><br>
<br>
Message:<br>
<textarea rows="9" name="message" cols="30"></textarea><br>
<br>
<a href="javascript: submitform()" >Searchthis</a>
</form>
</body>
PHP FILE:
<?php
$to = "[email protected]";
$subject = "ABCs of UFOs";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
?>
I was hoping someone could tell me how to edit this contact form so that it does not redirect to another page (the php page)? I'd like it to just simply send the message without leaving the page. The trick here is that I am using a javascript link to submit the form, NOT a button...
Any help would be most appreciated!
HTML PAGE:
<body>
<script type="text/javascript">
function submitform()
{
document.forms["form"].submit();
}
</script>
<form id= "form" method="POST" name="form" action="mailer.php">
Name:
<input type="text" name="name" size="19"><br>
<br>
E-Mail:
<input type="text" name="email" size="19"><br>
<br>
Message:<br>
<textarea rows="9" name="message" cols="30"></textarea><br>
<br>
<a href="javascript: submitform()" >Searchthis</a>
</form>
</body>
PHP FILE:
<?php
$to = "[email protected]";
$subject = "ABCs of UFOs";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
?>
Comment