Thursday, 25 February 2016

How to creat form in php

 index.php


<html>
<head>
<title></title>
<style>
body{font:90% Arial, Helvetica, sans-serif;
margin:20px;}
.wrap
{
    width:570px;
    height:533px;
    border:1px solid 000;
    background:pink;
    margin:0 auto;
    border-radius:10px;
}
label
{
    color:red;
    float:left;
    width:8em;
    text-align:left;
}
input
{
    width:20em;
    margin-left:1.5em;
    margin-bottom:.5em;
}
#Submit
{
    border:2px solid navy;
    width:8em;
    margin-left: 10.2em;
}
#Reset
{
    border:2px solid navy;
    width:5em;
}

</style>
</head>
<body>
<div class="wrap">

<fieldset>
<legend><i><b>A Simple Application Form</b></i></legend>

<h1><b><i><u>TechNode Computer Training Institute<i></u></b></h1>

</fieldset>

<fieldset>
<legend><i>TechNode Inc Kubernath Kushinagar Uttar-Pradesh(274304)</i></legend>
<form method="POST" action="project.php">
<label>First Name:</label>
<input type="text" name="firstname" id="firstname" autofocus><br>
<label>Last Name:</label>
<input type="text"  name="lastname" id="lastname" ><br>
<label>Address:</label>
<input type="text" name="address" id="address"><br>
<label>City:</label>
<input type="text" name="city" id="city"><br>
<label>State:</label>
<input type="text" name="state" id="state"><br>
<label>Zip Code:</label>
<input type="text" name="zipcode" id="zipcode"><br>
<label>Post:</label>
<input type="text" name="post" id="post"><br>
<label>Dist:</label>
<input type="text" name="dist" id="dist"><br>
<label>Contry:</label>
<input type="text" name="contry" id="contry"><br>
<label>Phone:</label>
<input type="text" name="phone" id="phone"><br>
<label>E-mail:</label>
<input type="text" name="email" id="email"><br>

<input type="submit" id="Submit" >  <input type="Reset" id="Reset">



</fieldset>
</form>
</div><!--end wrap-->
</body>
</html>


project.php
<?php
if(count($_POST)>0){
    foreach($_POST as $key=>$value){
        if(empty($_POST[$key]))    {
            $message = ucwords($key) . " Field is required";
            break;
           
        }
   
    }

$firstname = $_POST['firstname'];
$lastname     = $_POST['lastname'];
$address   = $_POST['address'];
$city  = $_POST['city'];
$state  = $_POST['state'];
$zip  = $_POST['zipcode'];
$post  = $_POST['post'];
$dist  = $_POST['dist'];
$contry  = $_POST['contry'];
$phone  = $_POST['phone'];
$email  = $_POST['email'];

   
}
?>
<!DOCTYPE html>
<html>
    <head>
            <style>
                    body{font:90% Arial, Helvetica, sans-serif;
margin:20px;}
.wrap
{
    width:570px;
    height:400px;
    border:1px solid 000;
    background:pink;
    margin:0 auto;
    border-radius:10px;
}
label
{
    color:red;
    float:left;
    width:8em;
    text-align:left;
}
input
{
    width:20em;
    margin-left:1.5em;
    margin-bottom:.5em;
}
.errors{color: red;}
</style>
</head>
<body>
    <div class="wrap">

<fieldset>
<legend><i><b>A Simple Application Form</b></i></legend>
<p class="errors"><?php echo $message ;?></p>
<h1><b><i><u>TechNode Computer Training Institute<i></u></b></h1>

</fieldset>

<fieldset>
<legend><i>TechNode Inc Kubernath Kushinagar Uttar-Pradesh(274304)</i></legend>

<label>First Name:</label>
<?php echo $firstname; ?>
<br>
<label>Last Name:</label>
<?php echo $lastname ;?>

<br>
<label>Address:</label>
<?php echo $address ;?>

<br>
<label>City:</label>
<?php echo $city ;?>

<br>
<label>State:</label>
<?php echo md5($zip) ;?>

<br>
<label>Post:</label>
<?php echo $post ;?>

<br>
<label>Dist:</label>
<?php echo $dist ;?>

<br>
<label>Contry:</label>
<?php echo $contry ;?>

<br>
<label>Phone:</label>
<?php echo $phone ;?>

<br>
<label>E-mail:</label>
<?php echo $email ;?>

</fieldset>
</div><!--end wrap-->
</body>
</html>

Result:





Krishna Kumar Gupta Powered By- TechNode Computer Kubersthan 274304.