This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

[Information] simple contactus page-php-code-demo


simple contactus page-php-code-demo

missionspot.blogspot.com - Simple contactus page-php-code-demo with javascript validation
<?php
session_start();
include "include/connection.php";
include "include/functions.php";
include "include/header.php";
//$r=getCMSPageContent(8);
$current_date=date('Y-m-d');
$msg='';

if(isset($_POST['submit_contact']))
{
$fname=trim($_POST['fname']);
$lname=trim($_POST['lname']);
$email=trim($_POST['email']);
$contact_no=trim($_POST['contact_no']);
$address=addslashes(trim($_POST['address']));
$ip_add=$_SERVER["REMOTE_ADDR"];

$sql="insert into `sp_contactus` set `fname`='$fname',
`lname`='$lname',
`email`='$email',
`contact_no`='$contact_no',
`address`='$address',
`ip_add`='$ip_add',
`creation_date`='$current_date'
";

$res=mysql_query($sql);
if($res)
{
$msg="Your contact details are recive ..";
}
}

?>

<div>
<div>
<div>
<div>
<h4>We are Located at :-</h4>
<p>
<address>
<strong>TestTeam</strong><br>
PO Box 654, Westmead,<br>
NSW, 26545<br>
Australia<br>

</address>

<address>
<strong>Email us at</strong><br>
<a href="mailto:#">info@test.com</a>
</address>
</p>
</div>
</div>
<div>
<p>

<form name="contact" action="" method="post">
<legend>Contact Us</legend>
<div>
<label for="inputEmail">First Name</label>
<div>
<input type="text" name="fname" placeholder="First Name">
</div>
</div>
<div>
<label for="inputEmail">Last Name</label>
<div>
<input type="text" name="lname" placeholder="Last Name">
</div>
</div>
<div>
<label for="inputPassword">Email Id</label>
<div>
<input type="email" name="email" placeholder="Email Id">
</div>
</div>
<div>
<label for="inputPassword">Contact No</label>
<div>
<input type="text" name="contact_no" placeholder="Contact No">
</div>
</div>
<div>
<label for="inputPassword">Address</label>
<div>
<textarea name="address" rows="5"></textarea>
</div>
</div>
<div>
<div>
<input type="hidden" name="submit_contact" value="submit_contact" >
<button type="button" onClick="return submit_contact_us()">Send</button>
</div>
</div>
</form>
</p>
</div>
</div>
<?php include("include/footer.php");?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script language="javascript">
function submit_contact_us()
{
var fname=$("#fname").val();
var lname=$("#lname").val();
var email=$("#email").val();
var contact_no=$("#contact_no").val();
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

if(fname=='')
{
alert('Please enter first name');
$("#fname").focus();
return false;
}
else if(lname=='')
{
alert('Please enter last name');
$("#lname").focus();
return false;
}
else if(email=='')
{
alert('Please enter your email');
$("#email").focus();
return false;
}
else if(!filter.test(email))
{
alert('Please provide a valid email address');
$("#email").focus();
return false;
}
else if(contact_no=='')
{
alert('Please enter your contact no');
$("#contact_no").focus();
return false;
}
else if(isNaN(contact_no))
{
alert('Contact no should be numeric');
$("#contact_no").focus();
return false;
}else {
document.contact.submit();
}
}


<?php if($msg!=''){ ?>
alert("<?php echo $msg; ?>");
<?php } ?>

</script>

other source : http://viva.co.id, http://seo-tips-tech.blogspot.com, http://detik.com

0 Response to "[Information] simple contactus page-php-code-demo "

Post a Comment

Contact

Name

Email *

Message *