The form is hidden when the page loads and shows up when the Send us mail is clicked, I've been able to do it in such a way that when a user clicks on the Send us mail button the form will slide down, using jquery. but the challenge am having now is that when I click the button Send Mail the page reloads and this makes the jquery to run again and the form is hidden again. Though I've check the fields to be sure if they contain a value before submitting. But now even when the fields contain a value or not after clicking the Send Mail button in the form the page reloads and make the form to hide again. Please can anybody tell me what I can do to solve this problem? Thanks in anticipation.
Below is my php and jquery code:
<script type="text/javascript">
$(function(){
$("#contact_Holder").hide();
slideDown();
});
function slideDown(){
$("#slideDown").click(function() {
$("#contact_Holder").slideDown("normal");
});
$("#sendmail").click(function() {
$("#contact_Holder").show();
});
}
<?php
if(isset($_POST['sendmail']))
{
if(!(isset($_POST['txtname']) || ($_POST['txtsubject']) || ($_POST['txtmessage'])) || empty($_POST['txtname']) || empty($_POST['txtsubject']) || empty($_POST['txtmessage']))
{
echo '<font color="#090" size="3" face="Palatino Linotype,serif">'."please fill all fields thank you!".'</font>';
}
else
{
$to = 'info@mail.com';
$subject = $_POST['txtsubject'].' '.$_POST['txtname'];
$body = $_POST['txtmessage'];
if(mail($to,$subject,$body))
{
echo('<font color="#090" size="3" face="Palatino Linotype,serif">'."Your message has been sent successfully".'</font>');
}
else{ echo('<font color="#090" size="3" face="Palatino Linotype,serif">'."Message Delivery Failed!".'</font>'); }
}
}
?>