0% found this document useful (0 votes)
17 views

PHP and HTML Code To Insert Data To Database

Uploaded by

ajent gamers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

PHP and HTML Code To Insert Data To Database

Uploaded by

ajent gamers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Create a php program to insert student data to database.

SOURCE CODE:

W1.html

<html>
<head>

</head>
<body>

<h1 align="center"> STUDENT REGISTRATION</h1>

<form name="frmstudent" method="post" action="student.php">


Roll no: <input type="text" name="t1"><br><br>
First name: <input type="text" name="t2"><br><br>
Last Name :<input type="text" name="t3"><br><br>
<input type="submit" value="submit">
</form>
</body>
</html>

student.php

<?php
ini_set('display_errors', 1);
error_reporting(-1);
$con = mysqli_connect("localhost","kashi","dbpassword","studentphp");
$rno = $_POST['t1'];
$fname=$_POST['t2'];
$lname=$_POST['t3'];
$sql = "insert into students values ('$rno','$fname','$lname')";
$rs=mysqli_query($con,$sql);
if($rs)
{
echo " Records Inserted";
}
else
{
echo "Porblem";
}

?>
OUTPUT:

DATABASE:

You might also like