Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Samarth Polytechnic,Belhe

DEPARTMENT OF COMPUTER ENGINEERING

Subject: Web Based application development using PHP. Subject code: 22619

Semester: 6th Course: Computer Engineering


Name of Subject Teacher: Prof. Kshirsagar. S. B Laboratory No:L001B
Name of Student: Atkar Hitesh Shantaram Enrollment no: 1909920001
Date of Performance : / / 2022 Date of Submission: / / 2022

Experiment No: 15

Title of Experiment: Develop a simple application to –


a) Enter data into database
b) Retrieve and present data from database

Theory:
1.0 Title:
Develop a simple application to - a) Enter data into database b) Retrieve and present data from database

2.0 Practical Significance:

In PHP using MYSQL data can be enter into database . Also we can retrieve and present data from database.

3.0 Relevant Program Outcomes (POs)

 Basic Knowledge: Apply knowledge of basic mathematics, sciences and basic engineering to solve the
computer group related problem.
 Discipline Knowledge: Apply computer programming knowledge to solve the computer group related
problems.
 Experiments and practices: Plan to perform experiments and practices to use the result to solve the
computer group related problems.
 Engineering tools: Apply relevant Computer programming technologies and tools with an understanding
of the limitations.
 Individual and Teamwork: Function effectively as a leader and the team member in
diverse/multidisciplinary teams.
 Communication: Communicate effectively in oral and written form.

4.0 Practical Outcome (PrOs) :


1. Develop a program to enter data into database
2. Develop a program to retrieve and present data from database

5.0 Apparatus:

Sr.No. Equipment Name with broad specification Practical


1 Hardware : any computer system (preferably i3 or i5) All
2 Operating System: Windows/Linux All
3 Any Database tool such as MYSQL,MariaDB 15,16

6.0 Minimum Theoretical Background:-

Insert Data Into MySQL Using MySQLi


After a database and a table have been created, we can start adding data in them.
Syntax: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)

Program-
Index.php-
<!DOCTYPE html>
<html lang="en">
<head>
<title>GFG- Store Data</title>
</head>
<body>
<center>
<h1>Storing Form data in Database</h1>
<form action="insert.php" method="post">
<p>
<label for="firstName">First Name:</label>
<input type="text" name="first_name" id="firstName">
</p>
<p>
<label for="lastName">Last Name:</label>
<input type="text" name="last_name" id="lastName">
</p>
<p>
<label for="Gender">Gender:</label>
<input type="text" name="gender" id="Gender">
</p>
<p>
<label for="Address">Address:</label>
<input type="text" name="address" id="Address">
</p>
<p>
<label for="emailAddress">Email Address:</label>
<input type="text" name="email" id="emailAddress">
</p>
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Insert.php-
<!DOCTYPE html>
<html>
<head>
<title>Insert Page page</title>
</head>
<body>
<center>
<?php
// servername => localhost
// username => root
// password => empty
// database name => staff
$conn = mysqli_connect("localhost", "root", "", "staff");
// Check connection
if($conn === false){
die("ERROR: Could not connect. "
. mysqli_connect_error());
}
// Taking all 5 values from the form data(input)
$first_name = $_REQUEST['first_name'];
$last_name = $_REQUEST['last_name'];
$gender = $_REQUEST['gender'];
$address = $_REQUEST['address'];
$email = $_REQUEST['email'];

// Performing insert query execution


// here our table name is college
$sql = "INSERT INTO college VALUES ('$first_name',
'$last_name','$gender','$address','$email')";

if(mysqli_query($conn, $sql)){
echo "<h3>data stored in a database successfully."
. " Please browse your localhost php my admin"
. " to view the updated data</h3>";

echo nl2br("\n$first_name\n $last_name\n "


. "$gender\n $address\n $email");
} else{
echo "ERROR: Hush! Sorry $sql. "
. mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
</center>
</body>
</html>

Output-
Process Product Total Dated Sign Of
Related Related (25 M) Teacher
Grade and (15M) (10M)
Dated Signature of
Teacher

You might also like