hai friends!
In this Artical i am going to show you how to insert Data into Data Base by using PHP and MYSQL.
creating a new data dase and inserting data is very simple .
now we are going to create new data base by using the following steps.
here iam going to insert and display contact data into data base.
Step 1: In this step we are going to create a new form and save it as contact.php (you can save it by your intrest).
MKinventions
MKinventions
Enter Data
step 2:Display your data in display-data.php page.
MKinventions
MKinventions
Display Data
Sl.no
Name
Email
Address
Message
Date/Time
query("SELECT * FROM `contact_table`");
while($record=$sql->fetch_assoc())
{
?>
step 3:we required this code to connect with data base db_connection.php
connect_error)
{
die("connection failed:".$conn->connection_error);
}
?>
step 4:we need this code to insert data into Data Base ,all the contact form functionality works in this page ,this will helps to insert data into DB
query("INSERT INTO `contact_table`(`name`, `email`, `address`, `message`, `CreatedOn`)
VALUES('$name','$email','$address','$message',now())");
if($sql===TRUE)
{
echo"";
}
else
{
echo"";
echo $conn->error;
}
?>
step 5: Create Table in Data Base Table name as (contact_table) in apple DB
CREATE TABLE `contact_table` (
`id` int(20) NOT NULL,
`name` varchar(20) NOT NULL,
`email` varchar(50) NOT NULL,
`address` varchar(50) NOT NULL,
`message` varchar(200) NOT NULL,
`CreatedOn` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
0 Comments
Please do not Enter any Spam Link in the Comment Box
Emoji