Saturday, January 31, 2015

insert form data into mysql database using php

If you want to insert data into mysql database using php

if the database table is tblemployees


<form action="insert.php" method="POST">
<table>
<tr><td><input type="text" name="EMPNAME"/></td></tr>
<tr><td><input type="text" name="AGE"/></td></tr>
<tr><td><input type="text" name="MOBILE"/></td></tr>
<tr><td><input type="text" name="EMAIL"/></td></tr>
<tr><td><input type="submit" name="SUBMIT"/></td></tr>
</form>


and the php code to insert the data into database table is as follows

insert.php:

<?php


if(isset($_POST['submit'])=='SUBMIT')
{
     $insert=mysql_query("insert inot tblemployees (EMPNAME,AGE,MOBILE,EMAIL) values ('".$_POST['EMPNAME']."','".$_POST['AGE']."','".$_POST['MOBILE']."','".$_POST['EMAIL']."')");

if($insert)
{
   echo "Employee Created Successfully";
}

}

?>

No comments:

Post a Comment

How to get Logged In Username in Wordpress or Woocommerce

It is really easy to get the logged-in user’s information in Wordpress or Woocommerce. In this article we will show you how to get the relat...