Friday 7 February 2014

Submit A Form To MYSQL Databse Using PHP

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

Printing first 50 Fibonacci numbers Using PHP Program

Fibonacci series is a series of numbers in which each number is the sum of the two preceding numbers. For example. 0 , 1 , 1 , 2 , 3 , 5...