web-application programs
web-application programs
Code:
Output:
Program 2: Create an XHTML web page that demonstrates the use of
Hyperlinks.
Code:
Output:
Program 3: Create an XHTML web page that demonstrates the use of
images.
Code:
Output:
Program 4: Create an XHTML web page that demonstrates the usage of
ordered, unordered, and definition lists.
Code:
Output:
Program 5: Create an XHTML web page that demonstrates the usage of
simple tables in XHTML.
Code:
Output:
Program 6: Create an XHTML web page that demonstrates the usage of
tables in XHTML using cellspacing, cellpadding, rowspan, and colspan
attributes.
Code:
Output:
Program 7: Create an XHTML page that displays a form with all types of
controls.
Code:
<label for="gender">Gender:</label>
<input type="radio" id="male" name="gender" value="Male" />
Male
<input type="radio" id="female" name="gender"
value="Female" /> Female<br /><br />
<label for="city">City:</label>
<select id="city" name="city">
<option value="newyork">New York</option>
<option value="losangeles">Los Angeles</option>
</select><br /><br />
<label>Hobbies:</label>
<input type="checkbox" name="hobbies" value="Reading" />
Reading
<input type="checkbox" name="hobbies" value="Traveling" />
Traveling<br /><br />
Output:
Program 8: Develop a webpage and demonstrate the usage of inline,
internal, and external styles.
Code:
HTML File:
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Program 8: CSS Demonstration</title>
<style>
h1 { color: blue; } /* Internal CSS */
.text-green { color: green; }
</style>
<link rel="stylesheet" href="styles.css" /> <!-- External CSS >
</head>
<body>
<h1>CSS Styles Demonstration</h1>
<p style="color: red;">This is an inline style paragraph.</p>
<p class="text-green">This paragraph uses internal styling.</p>
<p class="external">This paragraph uses external styling.</p>
</body>
</html>
Output:
Program 9: Write a JavaScript function to find the second largest element
in an array.
Code:
Output:
Program 10: Develop a web page to demonstrate event handling
mechanisms using JavaScript.
Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Program 10: Event Handling</title>
<script>
function showMessage() {
alert("Button clicked!");
}
</script>
</head>
<body>
<h1>
Event Handling Demo
</h1>
<button onclick="showMessage()">Click Me</button>
</body>
</html>
Output:
Program 11: Install and configure PHP, web server, MySQL, and write
basic PHP programs.
Output:
Code:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to PHP</title>
</head>
<body>
<?php
echo "Welcome to PHP";
?>
</body>
</html>
Output:
Program 12: Write a PHP program to demonstrate the use of decision-
making control structures.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Decision Making in PHP</title>
</head>
<body>
<?php
$number = 10;
// If statement
if ($number > 0) {
echo "The number is positive.<br />";
}
// If-else statement
if ($number % 2 == 0) {
echo "The number is even.<br />";
} else {
echo "The number is odd.<br />";
}
// Switch statement
switch ($number) {
case 10:
echo "The number is 10.<br />";
break;
default:
echo "The number is not 10.<br />";
}
?>
</body>
</html>
Output:
Program 13: Write a PHP program for creating and manipulating arrays.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Array Manipulation</title>
</head>
<body>
<?php
// Indexed array
$indexed = [1, 2, 3, 4, 5];
echo "Indexed Array: " . implode(", ", $indexed) . "<br />";
// Associative array
$associative = ["Name" => "Alice", "Age" => 25];
echo "Name: " . $associative["Name"] . ", Age: " .
$associative["Age"] . "<br />";
// Multidimensional array
$multi = [
["Apple", "Red"],
["Banana", "Yellow"]
];
echo "First Fruit: " . $multi[0][0] . " - " . $multi[0][1];
?>
</body>
</html>
Output:
Program 14: Develop a web page with data validation.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Data Validation</title>
</head>
<body>
<form method="post" action="">
<label for="email">Email:</label>
<input type="text" id="email" name="email" />
<input type="submit" value="Submit" />
</form>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST["email"];
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Valid email address.";
} else {
echo "Invalid email address.";
}
}
?>
</body>
</html>
Output:
Program 15: Write a simple PHP program to set cookies and demonstrate
session management.
<!DOCTYPE html>
<html>
<head>
<title>Cookies Example</title>
</head>
<body>
<?php
// Set a cookie
setcookie("username", "Alice", time() + 3600, "/");
Output:
Code for Session Management:
<!DOCTYPE html>
<html>
<head>
<title>Session Management</title>
</head>
<body>
<?php
session_start(); // Start session
$_SESSION["user"] = "Alice"; // Set session variable
Output: