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>
<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