Index: Sr. No. Programs Remarks
Index: Sr. No. Programs Remarks
Index: Sr. No. Programs Remarks
0|Page
1. PHP Code to display today’s date in dd-mm-yyyy format.
<!DOCTYPE html>
<html>
<body>
<?php
?>
</body>
</html>
Output :-
1|Page
2. PHP Code to check if number is prime or not.
<?php
$MyNum = 17;
$n = 0;
if($MyNum % $i == 0){
$n++;
break;
if ($n == 0){
} else {
?>
Output:-
2|Page
3. PHP Code to print first 10 Fibonacci Numbers.
<?php
echo "<h3>Fibonacci series for first 12 numbers: </h3>";
function Fibonacci($number){
// Driver Code
$number = 10;
for ($counter = 0; $counter < $number; $counter++){
echo Fibonacci($counter),' ';
}
?>
Output :-
3|Page
4. PHP Code to read data from txt file and display it in html table (the file contains info in format
Name: Password: Email )
<?php
$lines = file("data.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$data = array_map(function ($v) {
list($username, $score) = explode(":", $v);
return ["username" => $username, "score" => $score];
}, $lines);
Output
4|Page
5. PHP Script for login authentication. Design an HTML form which takes username and password
from user and validate against stored username and password in file.
1)Login.php
<?php
// Read the file containing the stored username and password
$file = file_get_contents('login.txt');
$lines = explode("\n", $file);
$stored_username = trim($lines[0]);
$stored_password = trim($lines[1]);
// Check if the entered username and password match the stored values
if ($username == $stored_username && $password == $stored_password) {
echo "Login successful!";
} else {
echo "Invalid username or password.";
}
} else {
echo "Please submit the form.";
}
?>
2)auth.html
3)Login.txt
Output :
5|Page
HTML Form :
Login Authentication :
6|Page
6. PHP Script for user authentication using PHP-MYSQL. Use session for storing username.
Register.php
<html>
<head>
<title>Registration Page</title>
</head> <body>
<h1> Registration Page</h1><br />
Insert .php
if (!$con)
mysql_select_db("ivcse", $con);
if (!mysqli_query($con, $sql))
die('Error:'. mysqli_error());
echo "<br><br>";
mysqli_close($con);
?>
7|Page
8|Page
7. PHP Script for user authentication using PHP-MYSQL. Use session for storing username.
Auth.html
<!DOCTYPE html>
<html>
<head>
<title>Text File Storage</title>
</head>
<body>
<h2>Text File Storage</h2>
<form method="POST" action="store.php">
<label for="inputText">Enter Text:</label>
<input type="text" name="inputText" required><br><br>
<input type="submit" name="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
Store.php
<?php
if (isset($_POST['submit'])) {
$inputText = $_POST['inputText'];
Output
9|Page
8. Create XML documents for chosen application and validate using DTD and schema. Also render
the content of XML document using XSL. Scenarios include XML document must have attributes
and elements so that they can be validated against DTD/Schema. Check the data types of
variables declared in XML document using Schema. Display the details of data contained in XML
document in a table using XSL.
Book.xml
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="books.xsd">
<book id="1">
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<year>1925</year>
</book>
<book id="2">
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
<year>1960</year>
</book>
</library>
Books.dtd
<!DOCTYPE library [
<!ELEMENT library (book+)>
<!ELEMENT book (title, author, year)>
<!ATTLIST book id CDATA #REQUIRED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT year (#PCDATA)>
]>
Books.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded">
<xs:complexType>
10 | P a g e
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="year" type="xs:integer"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
11 | P a g e
Books.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<h2>Books</h2>
<table>
<tr>
<th>ID</th>
<th>Title</th>
<th>Author</th>
<th>Year</th>
</tr>
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
12 | P a g e
9. Modify the specific web applications to use AJAX to show the result on the same page.
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
// Attach event listener to the form submission
$('form').submit(function(event) {
event.preventDefault(); // Prevent default form submission
13 | P a g e
10. Create a responsive Photo Gallery in BOOTSTRAP
Bootsrap.html
<!DOCTYPE html>
<html>
<head>
<title>Responsive Photo Gallery</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
.gallery-container {
display: flex;
flex-wrap: wrap;
}
.gallery-item {
width: 300px;
margin: 10px;
}
.gallery-item img {
width: 100%;
height: auto;
}
</style>
</head>
<body>
<div class="container">
<h2>Photo Gallery</h2>
<div class="gallery-container">
<div class="gallery-item">
<img src="path/to/image1.jpg" alt="Image 1">
</div>
<div class="gallery-item">
<img src="path/to/image2.jpg" alt="Image 2">
</div>
<div class="gallery-item">
<img src="path/to/image3.jpg" alt="Image 3">
</div>
<!-- Add more gallery items as needed -->
</div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
Output
14 | P a g e
11. Suppose you have a list of Students having Student’s Name, Roll Number, Marks in five
subjects, Show this list in a responsive table in BOOTSTRAP
<!DOCTYPE html>
<html>
<head>
<title>Student List</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Student List</h2>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Roll Number</th>
<th>Subject 1</th>
<th>Subject 2</th>
<th>Subject 3</th>
<th>Subject 4</th>
<th>Subject 5</th>
</tr>
</thead>
<tbody>
<tr>
<td>Rohan</td>
<td>001</td>
<td>90</td>
<td>85</td>
<td>95</td>
<td>88</td>
<td>92</td>
</tr>
<tr>
<td>Mansi</td>
<td>002</td>
<td>88</td>
<td>92</td>
<td>78</td>
<td>85</td>
<td>90</td>
</tr>
<tr>
<td>Rahul</td>
<td>003</td>
<td>63</td>
<td>81</td>
<td>87</td>
<td>58</td>
<td>68</td>
15 | P a g e
</tr>
<tr>
<td>Parminder</td>
<td>004</td>
<td>88</td>
<td>99</td>
<td>71</td>
<td>83</td>
<td>91</td>
</tr>
<tr>
<td>Yash</td>
<td>005</td>
<td>89</td>
<td>97</td>
<td>72</td>
<td>81</td>
<td>93</td>
</tr>
<!-- Add more rows for other students -->
</tbody>
</table>
</div>
</div>
</body>
</html>
Output
16 | P a g e
12. Build a Registration Form and Validate it with JQuery. Registration Form must have at least 10
elements.
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
.error {
color: red;
}
</style>
</head>
<body>
<h2>Registration Form</h2>
<form id="registrationForm" method="post">
<div>
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
</div>
<div>
<label for="confirmPassword">Confirm Password:</label>
<input type="password" id="confirmPassword" name="confirmPassword" required>
</div>
<div>
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" required>
</div>
<div>
<label for="address">Address:</label>
<input type="text" id="address" name="address" required>
</div>
<div>
<label for="city">City:</label>
<input type="text" id="city" name="city" required>
</div>
<div>
<label for="state">State:</label>
<input type="text" id="state" name="state" required>
</div>
<div>
<label for="zip">Zip Code:</label>
<input type="text" id="zip" name="zip" required>
17 | P a g e
</div>
<div>
<label for="country">Country:</label>
<input type="text" id="country" name="country" required>
</div>
<br>
<input type="submit" value="Register">
</form>
<script>
$(document).ready(function() {
$('#registrationForm').submit(function(event) {
var name = $('#name').val();
var email = $('#email').val();
var password = $('#password').val();
var confirmPassword = $('#confirmPassword').val();
var phone = $('#phone').val();
var address = $('#address').val();
var city = $('#city').val();
var state = $('#state').val();
var zip = $('#zip').val();
var country = $('#country').val();
// Validation rules
var nameRegex = /^[a-zA-Z ]+$/;
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
var passwordRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z]{8,}$/;
var phoneRegex = /^\d{10}$/;
var zipRegex = /^\d{5}$/;
// Perform validation
if (!name.match(nameRegex)) {
$('#name').after('<span class="error">Please enter a valid name.</span>');
event.preventDefault();
}
If
Output
18 | P a g e
13. Create a Star Rating System in JQuery.
<!DOCTYPE html>
<html>
<head>
<title>Star Rating System</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
}
.rating span {
font-size: 30px;
cursor: pointer;
display: inline-block;
width: 30px;
margin-right: 5px;
}
.rating span:before {
content: "\2605";
}
.rating span.checked:before {
content: "\2605";
color: gold;
}
</style>
</head>
<body>
<h2 style="text-align: center; font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-
serif;">Star Rating System</h2><br>
<BR>
19 | P a g e
<span class="star" data-value="1"></span>
<span class="star" data-value="2"></span>
<span class="star" data-value="3"></span>
<span class="star" data-value="4"></span>
<span class="star" data-value="5"></span>
</div>
<script>
$(document).ready(function() {
$('.star').click(function() {
var value = $(this).data('value');
$('.star').removeClass('checked');
});
});
</script>
</body>
</html>
Output
20 | P a g e
14. Create a simple To-do list Application with REACT
// App.js File
import React, { Component } from "react";
import "bootstrap/dist/css/bootstrap.css";
import Container from "react-bootstrap/Container";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Button from "react-bootstrap/Button";
import InputGroup from "react-bootstrap/InputGroup";
import FormControl from "react-bootstrap/FormControl";
import ListGroup from "react-bootstrap/ListGroup";
// Setting up state
this.state = {
userInput: "",
list: [],
};
}
// Update list
const list = [...this.state.list];
list.push(userInput);
// reset state
this.setState({
list,
userInput: "",
});
}
}
21 | P a g e
const updateList = list.filter((item) => item.id !== key);
render() {
return (
<Container>
<Row
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
fontSize: "3rem",
fontWeight: "bolder",
}}
>
TODO LIST
</Row>
<hr />
<Row>
<Col md={{ span: 5, offset: 4 }}>
<InputGroup className="mb-3">
<FormControl
placeholder="add item . . . "
size="lg"
value={this.state.userInput}
onChange={(item) =>
this.updateInput(item.target.value)
}
aria-label="add something"
aria-describedby="basic-addon2"
/>
<InputGroup>
<Button
variant="dark"
className="mt-2"
onClick={() => this.addItem()}
>
ADD
</Button>
</InputGroup>
</InputGroup>
</Col>
</Row>
<Row>
<Col md={{ span: 5, offset: 4 }}>
<ListGroup>
{/* map over and print items */}
{this.state.list.map((item) => {
return (
<ListGroup.Item
variant="dark"
22 | P a g e
action
onClick={() =>
this.deleteItem(item.id)}
>
{item.value}
</ListGroup.Item>
);
})}
</ListGroup>
</Col>
</Row>
</Container>
);
}
}
23 | P a g e
15. Create a Calculator with REACT.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,
initial-scale=1, shrink-to-fit=no">
<title>GeeksforGeeks Calculator</title>
</head>
<body>
</body>
</html>
Output
24 | P a g e