Here is a html form:
Code: Select all
<html>
<head><title>Job Application</title></head>
<style type="text/css">
body {
border: 2% solid #dddddd;
margin: 4%;
padding: 4%;
}
.button {
border:1px inset #dddddd;
}
</style>
<body>
<center><form method="post" action="application.php">
<table border="1" cellpadding="2" cellspacing="0" width="75%" style="border-collapse:collapse;border-bottom:1px solid #dddddd;border-left:2px solid #ccc;border-right:2px solid #ccc;border-top:1px solid #dddddd;">
<tr><td><b>Name:</b></td><td><input type="text" name="name"/></td></tr>
<tr><td><b>Phone:</b></td><td><input type="text" name="phone"/></td></tr>
<tr><td><b>Email:</b></td><td><input type="text" name="email"/></td></tr>
<tr><td><b>Address:</b></td><td><textarea name="address"/></textarea></td></tr>
<tr><td><b>Gender:</b></td><td><b>Male:</b><input type="radio" name="gender" value="Male"/> <b>Female:</b><input type="radio" name="gender" value="female"/></td></tr>
<tr><td><b>City:</b></td><td><select name="city"><option>Karachi</option>
<option>Islamabad</option><option>Lahore</option></select></td></tr>
<tr><td><b>Age:</b></td><td><input type="text" name="age"/></td></tr>
<tr><td><b>Skills:</b></td><td><b>PHP:</b><input type="checkbox" name="skills[]" value="php"/><br /><b>MySQL:</b><input type="checkbox" name="skills[]" value="mysql"/><br /><b>HTML:</b><input type="checkbox" name="skills[]" value="html"/><br /><b>AJAX:</b><input type="checkbox" name="skills[]" value="ajax"/><br /><b>Flash:</b><input type="checkbox" name="skills[]" value="flash"/></td></tr>
<tr><td> </td><td><input type="submit" value="Submit" class="button"/> <input type="reset" value="Reset" class="button"/></td></tr>
</table>
</form></center>
</body>
</html>Code: Select all
<html>
<head><title>Process Application</title></head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
//Function for clean string
function cleanstr($clstr){
$cstr = trim($clstr);
$cstr = addslashes($clstr);
$cstr = htmlspecialchars($clstr);
return $cstr;
}
function emptyfields($empty){
if(!is_array($empty)){
echo "The argument must be in array";
return false;
}
foreach($empty as $required => $values){
$values = cleanstr($values);
if(empty($values)){
echo "<b>" . ucwords($required) . "</b> must not be empty";
return false;
}
}
return true;
}
//calling function to check any empty field
if(!emptyfields($_POST)){
exit();
}
$name = cleanstr($_POST['name']);
$phone = cleanstr($_POST['phone']);
$email = cleanstr($_POST['email']);
$address = cleanstr($_POST['address']);
$gender = $_POST['gender'];
$city = $_POST['city'];
$age = (int)cleanstr($_POST['age']);
$skills = $_POST['skills'];
echo "Your name is:". $name;
echo "Your Phone no is:". $phone;
echo "Your email is:". $email;
echo "Your address is:". $address;
echo "Your gender is:". $gender;
echo "Your city is:". $city;
echo "Your age is:". $age;
echo "Your skills: ";
foreach($skills as $value){
echo ($value).",";
}
?>
</body>
</html>