How insert data into Database in phpMyAdmin with help of form.

This is the method described below will help you to insert your form data into phpMyAdmin with easy code.




<html>
<body>

<form action="" method="POST">

       
    <table>
<tr>
<td>Name:</td><td><input type="text" name="S_name"><br /></td>
</tr>
        <tr>
<td>Gender:</td><td><input type="radio" name="gen" value="Male"> Male <input type="radio" name="gen" value="Female"> Female<br /></td>
</tr>
<tr>
<td>PHP:</td><td><input type="text" name="php"><br /></td>
        </tr>
<tr>
<td>ASP:</td><td><input type="text" name="asp"><br /></td>
</tr>
<tr>
<td>CN:</td><td><input type="text" name="cn"><br /></td>
</tr>
<tr>
<td>Unix:</td><td><input type="text" name="unix"><br /></td>
</tr>
<tr>
<td>OS:</td><td><input type="text" name="os"><br /></td>
</tr>
<tr>
<td>Practical:</td><td><input type="text" name="practical"><br /></td>
        </tr>
</table>
<br>
<input type="submit" name="sub" value="Submit">

</form>


<?php
include('connection.php');  // Connection file which contain connection code.

mysql_select_db('Student');

/*                ===========Manually===========

if(!mysql_query('insert into result(Name,Gender,PHP,ASP,CN,Unix,OS,Practical) values ("ABC","Male",80,85,90,88,96,97);'))
die("Query run unsuccessful and Data not inserted!!<br>Error ==> <font color='red'>".mysql_error());
else  
echo "Query run successful and Data inserted";

*/

$S_name = $_REQUEST['S_name'];
$gender = $_REQUEST['gen'];
$php = $_REQUEST['php'];
$asp = $_REQUEST['asp'];
$cn = $_REQUEST['cn'];
$unix = $_REQUEST['unix'];
$os =$_REQUEST['os'];
$practical = $_REQUEST['practical'];
$total = $php+$asp+$cn+$unix+$os+$practical;
$percentage = $total/6;

if(isset($_REQUEST['sub']))
{
if(!mysql_query("insert into result(Name,Gender,PHP,ASP,CN,Unix,OS,Practical,Total,Percentage) values ('$S_name','$gender','$php','$asp','$cn','$unix','$os','$practical','$total','$percentage');"))
{

die("Query run unsuccessful and Data not inserted!!<br>Error ==> <font color='red'>".mysql_error());

}
else

echo "<script type='text/javascript'>alert('Query run successful and Data inserted.......');</script>";
}

echo "<font color='red' size='5'><br>New Inserted Data : <br><font color='black' size='5'>= = = = = = = = = = =<br><font color='green' size='4'>";
echo $_REQUEST['S_name']."<br>".$_REQUEST['gen']."<br>".$_REQUEST['php']."<br>".$_REQUEST['asp']."<br>".$_REQUEST['cn']."<br>".$_REQUEST['unix']."<br>".$_REQUEST['os']."<br>".$_REQUEST['practical'];

}

?>
</body>
</html>



For any query comment and also contact with "Contact us forum".
Thank you.  

For other video tutorial visit channel ⏩⏩⏩

https://www.youtube.com/channel/UCUXIKbhnJ1_FcPqXcJFwzGg

Comments

:skin :include name='super.defaultAdUnit'/>