Here you can find the code please click below
DEMO
Index.php
<html>
<body>
<form action="save.php" method="post">
Name: <input type="text" name="name">
Course: <input type="text" name="course">
Age: <input type="text" name="age">
<input type="submit" value="Registered">
</form>
</body>
</html>
save.php
<?php
$con=mysqli_connect("localhost","root","ubuntu@12345556","practise");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO student (name, course, age) VALUES ('$_POST[name]','$_POST[course]','$_POST[age]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "Registered";
mysqli_close($con);
?>
Databse
db_name:- practise
Table_name:- student
student (table name)
id
|
name
|
course
|
age
|
1
|
Rituraj kumar
|
B.Tech
|
23
|
2
|
Robi tomar
|
Android
|
24
|
3
|
Shikha chaudhary
|
Asp.Net
|
23
|
4
|
Harshu
|
SEO
|
21
|
5
|
Neeraj
|
UI Developer
|
23
|
No comments:
Post a Comment