0% found this document useful (0 votes)
3 views5 pages

Group 1

The document outlines a group project with members listed and includes tasks related to creating a database and a table. It provides PHP code for connecting to a MySQL database and inserting form data into a table named 'contact_tb'. The code also includes error handling to confirm successful insertion of contact records.

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)
3 views5 pages

Group 1

The document outlines a group project with members listed and includes tasks related to creating a database and a table. It provides PHP code for connecting to a MySQL database and inserting form data into a table named 'contact_tb'. The code also includes error handling to confirm successful insertion of contact records.

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/ 5

GROUP MEMBERS

 ITEBENG TSAPI ATHUR DONAL


 NTOAGNI GIOVANI LARRY
 KAMYEM MEYOU IVAN
 KAMENI CHRISTIAN
 TASSE JORDAN

TASK 1
TASK 2
1. CREATE DATABASE arsha_db
2. CREATE TABLE contact_tb
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