WT Slip Solutions
WT Slip Solutions
php
<?php
// Start the session
session_start();
// To reset the page view count, you can uncomment the following line:
// unset($_SESSION['page_views']);
?>
-----------------------------------------------------------------------------------
-----------------
slip 4
earning_details.php
<?php
session_start();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Earning Details</title>
</head>
<body>
<h2>Enter Earning Details</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
method="post">
<label for="basic">Basic:</label>
<input type="text" name="basic" id="basic" required><br><br>
<label for="da">DA:</label>
<input type="text" name="da" id="da" required><br><br>
<label for="hra">HRA:</label>
<input type="text" name="hra" id="hra" required><br><br>
<input type="submit" value="Next">
</form>
</body>
</html>
employee_details.php
<?php
session_start();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Details</title>
</head>
<body>
<h2>Enter Employee Details</h2>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
method="post">
<label for="eno">Employee Number:</label>
<input type="text" name="eno" id="eno" required><br><br>
<label for="ename">Employee Name:</label>
<input type="text" name="ename" id="ename" required><br><br>
<label for="address">Address:</label>
<input type="text" name="address" id="address" required><br><br>
<input type="submit" value="Next">
</form>
</body>
</html>
employee_info.php
<?php
session_start();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee Information</title>
</head>
<body>
<h2>Employee Information</h2>
<p><strong>Employee Number:</strong> <?php echo $employee_details['eno'];
?></p>
<p><strong>Employee Name:</strong> <?php echo $employee_details['ename'];
?></p>
<p><strong>Address:</strong> <?php echo $employee_details['address']; ?></p>
<p><strong>Basic:</strong> <?php echo $earning_details['basic']; ?></p>
<p><strong>DA:</strong> <?php echo $earning_details['da']; ?></p>
<p><strong>HRA:</strong> <?php echo $earning_details['hra']; ?></p>
<p><strong>Total Earnings:</strong> <?php echo $total; ?></p>
</body>
</html>
-----------------------------------------------------------------------------------
----------------------------------------
slip10.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert Text using jQuery</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function(){
// Insert text before the paragraph
$("#addBefore").click(function(){
$("p").before("<b>text to added</b> ");
});
filename:-books.xml
<books>
<book>
<title>Book 1</title>
<author>Author 1</author>
<year>2020</year>
<price>10.99</price>
</book>
<book>
<title>Book 2</title>
<author>Author 2</author>
<year>2019</year>
<price>15.99</price>
</book>
<book>
<title>Book 3</title>
<author>Author 3</author>
<year>2018</year>
<price>12.50</price>
</book>
</books>
filename:-get_books_details.php
<?php
$books = simplexml_load_file('books.xml');
$title = $_GET['title'];
filename:-index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Book Details</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<label for="bookSelect">Select a Book:</label>
<select id="bookSelect">
<option value="">--Select a book--</option>
<option value="Book 1">Book 1</option>
<option value="Book 2">Book 2</option>
<option value="Book 3">Book 3</option>
</select>
<div id="bookDetails"></div>
<script>
$(document).ready(function () {
$('#bookSelect').change(function () {
var selectedBook = $(this).val();
$.ajax({
url: 'get_book_details.php',
method: 'GET',
data: {title: selectedBook},
success: function (response) {
$('#bookDetails').html(response);
}
});
});
});
</script>
</body>
</html>
-----------------------------------------------------------------------------------
-------------------
slip17.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Registration</title>
<script>
window.onload = function() {
alert("Hello! Good Morning");
};
function registerStudent() {
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var age = document.getElementById("age").value;
<label for="email">Email:</label><br>
<input type="email" id="email" name="email"><br><br>
<label for="age">Age:</label><br>
<input type="number" id="age" name="age"><br><br>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fibonacci Numbers</title>
</head>
<body>
<h2>Fibonacci Numbers</h2>
<button onclick="printFibonacci()">Print Fibonacci Numbers</button>
<div id="fibonacciList"></div>
<script>
function printFibonacci() {
var fibonacciList = document.getElementById("fibonacciList");
fibonacciList.innerHTML = ""; // Clear previous results
if (isNaN(n) || n <= 0) {
alert("Please enter a valid positive number.");
return;
}
if (n >= 1) {
fibonacciList.innerHTML += fibSeries[0] + "<br>";
}
if (n >= 2) {
fibonacciList.innerHTML += fibSeries[1] + "<br>";
}
-----------------------------------------------------------------------------------
------------------
slip19.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
</head>
<body>
<h2>Login Form</h2>
<form onsubmit="return validateForm()">
<label for="username">Username:</label><br>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>
<script>
function validateForm() {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
// Validation rules
if (username.trim() === "") {
alert("Please enter a username.");
return false;
}
filename:-students.xml
filename:-view.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>View Students</title>
</head>
<body>
<h2>Student Information</h2>
<table border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Grade</th>
<th>Age</th>
<th>City</th>
</tr>
<?php
// Load XML file
$xml = simplexml_load_file('students.xml');
filename:-index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voter Registration</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<h2>Voter Registration Form</h2>
<form id="voterForm" onsubmit="return validateForm()">
<label for="name">Name (Upper Case Letters Only):</label><br>
<input type="text" id="name" name="name"><br><br>
<div id="message"></div>
<script>
function validateForm() {
var name = $('#name').val();
var age = $('#age').val();
var nationality = $('#nationality').val();
filename:-submit.php
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$nationality = $_POST['nationality'];
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Operations</title>
</head>
<body>
<h2>Number Operations</h2>
<form method="post" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
Enter a number: <input type="text" name="number">
<input type="submit" name="submit" value="Submit">
</form>
<?php
// Function to generate Fibonacci series
function fibonacci($n) {
$fib = [];
$fib[0] = 0;
$fib[1] = 1;
for ($i = 2; $i < $n; $i++) {
$fib[$i] = $fib[$i - 1] + $fib[$i - 2];
}
return $fib;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$number = $_POST["number"];
if (is_numeric($number)) {
echo "<h3>Results:</h3>";
echo "Input Number: $number <br>";
// Fibonacci series
echo "<h4>Fibonacci Series:</h4>";
$fibSeries = fibonacci($number);
echo implode(", ", $fibSeries) . "<br>";
// Sum of digits
echo "<h4>Sum of Digits:</h4>";
echo "Sum: " . sumOfDigits($number);
} else {
echo "<p style='color: red;'>Please enter a valid number.</p>";
}
}
?>
</body>
</html>
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------