HomeSunday, June 24, 2018, 01:36:21
1

Process Form Data with Jquery

Tuesday, February 10, 15, 00:54:32, 3 Yaers Ago Via wain, Hits: 6275
jQuery, Process form data
contact.php

Code:
<head>
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){$("a.send").click(function(){
var jname=$("#jname").val();
var jemail=$("#jemail").val();
var jfeed=$("#jfeed").val();
$.post("insert.php",{jname:jname,jemail:jemail,jfeed:jfeed},function(data){$("#loadc")
//.html(data), Get the HTML contents of the
//first element in the set of matched elements.
.html(data)
//Drops the element away or shows it by dropping it in.
.show('drop', { direction: 'left' }, 250);
});
});
});
</script>
</head>
<body>
<div align="center">
<div id="effect" align="center">
<div><h4>Contact Us</h4></div>
Name:<br /><input type="text" id="jname" name="jname"><br />
Email:<br /><input type="text" id="jemail" name="jemail"><br />
Message:<br /><textarea name="jfeed" id="jfeed" rows="8" cols="25"></textarea><br />
<a href="javascript:submit();" id="start" class="send">Contact Us</a>
<div id="loadc"></div>
</div>


insert.php

Code:
<?php
$email = '[email protected]';
$jname = $_POST['jname'];
$jemail = $_POST['jemail'];
$jfeed = $_POST['jfeed'];
$name = array($jname, $jemail, $jfeed);
foreach ($name as $name) {
if (preg_match("/</", $name)) {
echo "<center><div id=\"toprow\">Invalid Characters \"<\" HTML is not allowed";
Die();
}
if (strlen($name) < 5) {
echo "Field must be at least 3 characters long";die();
}
if (strlen($name) > 80) {
echo "Max Characters Field: 80";die();
}}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $jemail)) {
echo "Should be Valid email address.";
die();
}
$time = date("h:i A");
$date = date("l, F jS, Y");
$ip = $_SERVER['REMOTE_ADDR'];
$headers = 'From: System Admin';
$subject = "Info";
$bodys = "Message:\n\n$jfeed\n\nContact Us Form\n\n$date at $time.\n\n
IP Address.$ip \n\nE Address: $jemail\n\nName: $jname \n\n";
mail($email, $subject, $bodys, "From: $email");
echo "Thank You.";
?>

Sign In

Sponsor
Related

PHP highlight_string - PHP Tutorial

Outputs or returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP. Requirement(s): PHP Server.

Upload Attachment - PHP Tutorial

Upload attachment with PHP example, Requirement(s): PHP server

Addslashes - Stripslashes

addslashes — quote string with slashes, stripslashes — un-quotes a quoted string

PHP Str_replace - PHP Tutorial

This function returns a string or an array with all occurrences of search in subject replaced with the given replace value.

Upload Image With PHP

[Example3] Tutorial - How to upload image in php.

PHP str_replace

str_replace - This function returns a string or an array with all occurrences of search in subject replaced with the given replace value

PHP form with image upload

Advanced Contact Form with email and form field validation.It allows your visitors to send you an email directly from your website.Features: Image Upload, HTML Output, Captcha Image.

Sending HTML Email With Images - PHP Tutorial

Sending HTML Email With Images - Upload Image with PHP - Creating Dynamic Webpages Using PHP and MySQL - Select, Delete, Update..

Syntax highlighting in Smarty

Syntax highlighting for Smarty - Google Code Prettify

Creating a CAPTCHA with PHP :: PHP Tutorial

Captcha Image, This tutorial will show you how to create a form with Captcha.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Sun, Mar 18, 18
So far has created 115 entries.
wain
This author has not yet filled in any details.