0% found this document useful (0 votes)
6 views2 pages

Group 1

The document contains PHP code for inserting form data into a MySQL database named 'arsha_db'. It establishes a connection to the database, retrieves form input values, and executes an SQL INSERT statement to add the data to the 'contat_tb' table. Upon successful insertion, it outputs a confirmation message 'Contact Records Inserted'.

Uploaded by

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

Group 1

The document contains PHP code for inserting form data into a MySQL database named 'arsha_db'. It establishes a connection to the database, retrieves form input values, and executes an SQL INSERT statement to add the data to the 'contat_tb' table. Upon successful insertion, it outputs a confirmation message 'Contact Records Inserted'.

Uploaded by

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

TASK 3

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<form action="a.php" method ="post" enctype ="multipart / form -data">

<?php

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "arsha_db";

$con = mysqli_connect('localhost', 'root', '', ’arsha_db’);

?>

The “db_contact” is our database name that we created before.

After connection database you need to take post variable from the form. See the below code

<?php

$txtName = $_POST['txtname'];

$txtEmail = $_POST['txtemail'];

$txtPhone = $_POST['txtsubject'];

$txtMessage = $_POST['txtmessage'];

?>

<?php

$sql = "INSERT INTO `contat_tb` (`Id`, `your name`, `your email`, `subject`, `Message`) VALUES ('0',
'$txtname', '$txtemail', '$txtsubject', '$txtmessage');"

?>

<?php
$rs = mysqli_query($con, $sql);

?>

Here is PHP code for inserting data into your database from a form.

<?php

// database connection code

// $con = mysqli_connect('localhost', 'database_user', 'database_password','database');

$con = mysqli_connect('localhost', 'root', '','arsha_db');

// get the post records

$txtName = $_POST['txtname'];

$txtEmail = $_POST['txtemail'];

$txtPhone = $_POST['txtsubject'];

$txtMessage = $_POST['txtmessage'];

// database insert SQL code

$sql = "INSERT INTO `contat_tb` (`Id`, `your name`, `your email`, `subject`, `message`) VALUES ('0',
'$txtname', '$txtemail', '$txtsubject', '$txtmessage')";

// insert in database

$rs = mysqli_query($con, $sql);

if($rs)

echo "Contact Records Inserted";

?>

<?php

You might also like