I made this form to get full detail from client that how can we deal with him.
still this contact form is incomplete but I'll complete it in further post.
I made a stylesheet.css fileHere ; I made id for table to use it. As we know, id is used for unique element.
@charset "utf-8";
/* CSS Document */
#table_bg
{
border:5px;
border:solid;
background-color:#0F9;
border-collapse:separate;
}
Now I made a contact.html fileThis form output is same as given image in this post.
I used table to align form perfectly
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Form</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<body>
<table cellpadding="3" id="table_bg" align="center">
<form action="processing.php" method="get" >
<tr><td><label for="name"><strong>Full Name:</strong></label></td>
<td><input type="text" name="name" placeholder="Full Name" maxlength="20" style="width:250px;"/></td></tr>
<tr><td><label for="number"><strong>Personal Number:</strong></label></td>
<td><input type="text" name="number" placeholder="00923234223945" maxlength="16" style="width:250px;"/></td></tr>
<tr><td><label for="email"><strong>Email:</strong></label></td>
<td><input type="text" name="email" placeholder="i.e. example@mail.com" style="width:250px;"/></td></tr>
<tr><td><label for="gender"><strong>Your Gender:</strong></label></td>
<td><input type="radio" name="gender" value="Male" />Male
<input type="radio" name="gender" value="Female"/ >Female</td></tr>
<tr><td><label for="department"><strong>Contact Department:</strong></label></td>
<td><input type="checkbox" name="department" value="Marketing_Department" />Marketing Department
<input type="checkbox" name="department" value="Development_Department" />Development Department</td></tr>
<tr><td><label for="select"><strong>Contact Person:</strong></label></td>
<td><select name="select" >
<option>Online Supporter</option>
<option>SEO, SMO Agent</option>
<option>SEM, SMM Agent</option>
<option>Development Agent</option>
<option>Consultancy Agent</option>
<option>HR Agent</option>
</select></td></tr>
<tr><td><label for="subject"><strong>Subject:</strong></label></td>
<td><input type="text" name="subject" placeholder="Type Subject" style="width:250px;"/></td></tr>
<tr><td valign="top" align="left"><label for="gender"><strong>Your Gender:</strong></label></td>
<td><textarea cols="50" rows="20" name="message" placeholder="Write your message"></textarea></td></td>
<tr><td> </td>
<td><input type="submit" value="Send" /> <input type="reset" value="Clear" /> </td></tr>
</form>
</table>
</body>
</html>
Now I created a file processing.phpI needed to create this file for security. As we know, xHTML language runs on user side and PHP runs on Server side.
with $_GET[] Method, anyone can easily hack your code, that's why PHP is important to add creativity.
Features of Code:
- No value will be empty, User needs to enter all values
- If user will leave any value empty, form will redirect back to contact.html
- If user leaves spaces, form will trim them automatically
- HTML, Java code will not run in it.
- Back slash will not run in it
- User needs to write more than 25 characters in subject, more than 16 in message box, name maximum 20, number maximum 16
<?php
require_once("form_validation.php");
#1st Form values should not be empty.
if (isset($_GET['name'] , $_GET['number'] , $_GET['email'], $_GET['gender'] , $_GET['department'], $_GET['select'], $_GET['subject'], $_GET['message'])
&& $_GET['name']!="" && $_GET['number']!="" && $_GET['email']!="" && $_GET['subject']!="" && $_GET['message']!="")
{
if (strlen($_GET['name']) > 20 || strlen($_GET['number']) > 16 || strlen($_GET['email']) > 25 || strlen($_GET['subject']) < 25 || strlen($_GET['message']) < 160)
{
header("Location: contact.html");
exit;
}
$name = form_validation($_GET['name']);
$number = form_validation($_GET['number']);
$email = form_validation($_GET['email']);
$gender = $_GET['gender'];
$department = $_GET['department'];
$select = $_GET['select'];
$subject = form_validation($_GET['subject']);
$message = form_validation($_GET['message']);
echo "Name is : $name <br />
Number is : $number <br />
email is : $email <br />
Gender is : $gender <br />
Contact Department is : $department <br />
Subject is : $subject <br />
Agent is : $select <br />
Message is : $message <br />
";
}
else
{
header("Location: contact.html");
exit;
}
?>
Now I created a function file with form_validation.phpIn this function, it will use trim function to trim white spaces.
It will utilize HTML characters in whole form.
It will leave back slashes.
<?php
function form_validation($input)
{
$input = trim($input);
$input = htmlspecialchars($input);
$input = stripcslashes($input);
return $input;
}
?>
Good Luck. Form is upgraded in further post.
+ comments + 5 comments
lol :>)
http://www.php.net/manual/en/function.filter-input.php
can someone hel pe on my thesis.. online enrollment system with automatic sectioning for highschool.. pls. email me. noriennarciso@yahoo.com.. thank you
Describe here dear. We'll try to help you in your thesis.
Dear but you can not describe everything every time with single function.
Post a Comment
Give your reviews about this blog. Leave your comments. what do you think about this post?
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.
---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards