How to Insert Record in PHP GUI Application
by TechVidvan Team
Program 1
<html>
<body>
<center>
<form>
<table border=1>
<tr>
<th>Student Id</th>
<td><input type=text name=txtid></td>
</tr>
<tr>
<th>Name</th>
<td><input type=text name=txtname></td>
</tr>
<tr>
<th>Physics</th>
<td><input type=text name=txtphy></td>
</tr>
<tr>
<th>Chemistry</th>
<td><input type=text name=txtchem></td>
</tr>
<tr>
<th>Maths</th>
<td><input type=text name=txtmath></td>
</tr>
<tr>
<td></td>
<td><input type=submit value=Submit name=btnSubmit></td>
</tr>
</table>
<pre>
<?php
?>
</pre>
</center>
</body>
</html>Program 2
<html>
<body>
<center>
<form method=post action="InsertStudent.php">
<table border=1>
<tr>
<th>Student Id</th>
<td><input type=text name=txtid></td>
</tr>
<tr>
<th>Name</th>
<td><input type=text name=txtname></td>
</tr>
<tr>
<th>Physics</th>
<td><input type=text name=txtphy></td>
</tr>
<tr>
<th>Chemistry</th>
<td><input type=text name=txtchem></td>
</tr>
<tr>
<th>Maths</th>
<td><input type=text name=txtmath></td>
</tr>
<tr>
<td></td>
<td><input type=submit value=Submit name=btnSubmit></td>
</tr>
</table>
<pre>
<?php
if(isset($_POST['btnSubmit']))
{
$id=$_POST['txtid'];
$name=$_POST['txtname'];
$phy=$_POST['txtphy'];
$chem=$_POST['txtchem'];
$math=$_POST['txtmath'];
$mycon=mysqli_connect("localhost","root","","Library") or die("Connection not success");
echo "Connection sucees<br>";
//echo $id." ".$name." ".$phy." ".$chem." ".$math." ";
$sql="insert into studentdata values(".$id.",'".$name."',".$phy.",".$chem.",".$math.")";
$mycon->query($sql) or die("Error in Querry");
echo "<font color=green size=5>Record inserted........</font>";
}
?>
</pre>
</center>
</body>
</html>
Tags: how to insert record in php gui applicationinsert record in php gui applicationPHPphp gui applicationphp practicalphp program
TechVidvan Team
TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.