Saturday, January 11, 2014

PHP Code for Inserting Data

<html>
<head>
<style type="text/css">

    ul {
    list-style: none;
    margin: 0;
    }
    li {
    float: left;
    }
    a {
    background: #404853;
    background: linear-gradient(#687587, #404853);
    border-left: 1px solid rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    display: block;
    font-size: 18px;
    font-weight: bold;
    padding: 0 23px;
    line-height: 44px;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6);
    text-transform: uppercase;
    }
   
    a:link {
    text-decoration:none;
    color:#000000;
    }

    a:active {
    text-decoration:none;
    color:#FFF;
    background:21B9FF;
    }

    a:visited {
    text-decoration:none;
    color:#000000;
    }

    a {
    text-decoration:none;
    color:#000000;
    }

    a:hover, a.current {  
    color:#FFF;            
    background-color:#21B9FF;
    }
</style>
</head>

<body bgcolor = "#33CCFF">
<P><center>
    <ul>
    <li><a href = "home.html"> HOME </a></li>
    <li><a class= "current" href = "data.html"> INSERT DATA </a></li>
    <li><a href = "upData.html"> UPGRADE DATA </a></li>
    <li><a href = "previous_comp.php"> LIST OF PREVIOUS COMPANY </a></li>
    <li><a href = "company_end.php"> LIST OF COMPANY END IN 3 MONTHS </a></li>
    </ul>
</center></P>

<br /><br /><br />
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());

$name = $_POST["name"];
$company = $_POST["company"];
$address = $_POST["address"];
$owner = $_POST["owner"];
$pNum = $_POST["pnum"];
$start = $_POST["start"];
$end = $_POST["end"];
$contract = $_POST["contract"];
$rent = $_POST["rent"];
$cat = $_POST["category"];
$status = $_POST["status"];

if($_SERVER['REQUEST_METHOD']=="POST")
{
mysql_query("INSERT INTO detail (premise_name,company_name,address,owner_name,phone_num,date_start,date_end,contract,rent,category,status)
VALUES('$name','$company','$address','$owner','$pNum','$start','$end','$contract','$rent', '$cat','$status')")
or die(mysql_error());

echo '<p><H2>Data has been insert to MySQL</H2> ';
echo '</p>';

echo '<p><H3>THE INFORMATION OF PREMISE</H3></p>';
echo '<br />';

echo '<ul>';
echo '<b>THE PREMISE NAME :  </b>' . $name;
echo '<p>';
echo '<br />';

echo '<b>THE NAME OF COMPANY :  </b>' . $company;
echo '<p>';
echo '<br />';

echo '<b>ADDRESS OF COMPANY :  </b>' . $address;
echo '<p>';
echo '<br />';

echo '<b>OWNER NAME OF COMPANY :  </b>' . $owner;
echo '<p>';
echo '<br />';

echo '<b>CONTACT NUMBER OF COMPANY :  </b>' . $pNum;
echo '<p>';
echo '<br />';

echo '<b>THE DATE START OF CONTRACT :  </b>' . $start;
echo '<p>';
echo '<br />';

echo '<b>THE DATE END OF CONTRACT :  </b>' . $end;
echo '<p>';
echo '<br />';

echo '<b>YEAR OF CONTRACT :  </b>' . $contract;
echo '<p>';
echo '<br />';

echo '<b>RENT PER MONTH : RM</b>' . $rent;
echo '<p>';
echo '<br />';

echo '<b>CATEGORY OF COMPANY :  </b>' . $cat;
echo '<p>';
echo '<br />';

echo '<b>STATUS OF COMPANY :  </b>' . $status;
echo '</ul>';
}
else
echo "PLEASE FULFILL THE FORM";
?>
</body>
</html>

0 comments:

Post a Comment