Professional Documents
Culture Documents
Connect To Mysql Server: Create Database If Else
Connect To Mysql Server: Create Database If Else
Lab -11:-
Create an HTML document which contain a text field for entering the firstname of an employee and
a button with the label “Get Details”. Write a PHP script to display the details of concerned
employees in tabular format when the user enters the firstname in the text field and click on the
button.
Database.php
<?php
// Connect to MySQL server
$servername = "localhost";
$username = "CSELAB";
$password = "123";
$conn = mysqli_connect($servername, $username, $password);
mysqli_close($conn);
?>
form.html
<!DOCTYPE html>
<html>
<head>
<title>Employee Details</title>
</head>
<body>
<h1>Enter Firstname to get Employee Details</h1>
<form action="get_employee_details.php" method="post">
Firstname: <input type="text" name="firstname"><br>
<input type="submit" value="Get Details">
</form>
</body>
</html>
get_employee_details.php
<?php
// Connect to MySQL server
$servername = "localhost";
$username = "CSELAB";
$password = "123";
mysqli_close($conn);
2) Write a PHP script to access the data from the following “books.xml” file and display the data in
tabular format
books.xml
main.php
<?php
// Load XML file
$xml = simplexml_load_file("books.xml");