How to insert values in database from PHP Form.
1 Create Form in html.
2 Create table in your DB (Data base).
3 create connection file in php and connect db with your application.
// Code For This Task. //
<!DOCTYPE html>
<html>
<body>
<?php
include"config.php";
print_r($_POST);
$sql="insert into employer(emp_name,emp_address,mobile_number,salary) values('".$_POST['Emp-Name']."','".$_POST['Emp_Address']."','".$_POST['Mobile_Nomber']."','".$_POST['Salary']."')";
mysql_query($sql);
?>
<form action="index.php" method="post" enctype="application/x-www-form-urlencoded" name="Save" target="_self">
<table width="20%" border="1">
<tr>
<td>Id;</td>
<td><input name="id" type="text" size="20">;</td>
</tr>
<tr>
<td>Emp-Name;</td>
<td><input name="Emp-Name" id="Emp-Name " type="text" size="20"></td>
</tr>
<tr>
<td>Emp- Address;</td>
<td><input name="Emp_Address" id="Emp_Address" type="text" size="20"></td>
</tr>
<tr>
<td>Mobile Nomber;</td>
<td><input name="Mobile_Nomber"id="Mobile_Nomber" type="text" size="20"></td></td>
</tr>
<tr>
<td>Salary;</td>
<td><input name="Salary"id="Salary" id="salary " type="text" size="20"></td>
</tr>
<tr>
<td colspan="2"> <input name="submit"id="submit "type="submit" value="submit"><input name="action"id="action "type="hidden" value="save"></td>
</tr>
</table>
<input name="Mobile Nomber;" type="text" size="20">
</form>
</body>
</html>
Comments
Post a Comment