WEB PROGRAMMING PRACTICAL Ap
WEB PROGRAMMING PRACTICAL Ap
EXERCISE:
1. Make your college time table using HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<title>College Timetable</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2>College Timetable</h2>
<table>
<tr>
<th>Time/Day</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
<tr>
<td>8:00 - 9:30</td>
<td>web programming </td>
<td>toc</td>
<td>AJP</td>
<td>M$I</td>
<td>IPDC</td>
</tr>
<tr>
<td>2:00 - 3:30</td>
<td>TOC</td>
<td>IPDC</td>
<td>WEBPROGRAMMING</td>
<td>IOT</td>
<td>IOT</td>
</tr>
</table>
</body>
</html>
OUT PUT:
HTML stands for Hypertext Markup Language. It is the standard markup language
used for creating web pages and web applications
The HTML tag used to make text bold is the <strong> tag.
Example:
<p>This is <strong>bold</strong> text.</p>
The HTML tag used to create an unordered list is the <ul> tag.
example:
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
5. Which character indicates closing of a tag?
The character that indicates the closing of an HTML tag is the forward slash (/). It is used
right after the tag name to mark the end of the tag. For example:
<p>This is a paragraph.</p>
<html>
<head>
<title>Registration Form</title>
<style> body{ background-color:powderblue;
</style>
</head>
<body
<h2>Registration From</h2>
<form>
<lable>Enter full Name:</lable>
<input type="text" id="fname"> <br><br>
<lable>Email id:</lable>
<input type="text" id="fname"> <br><br>
<lable>password:</lable>
<input type="password" id="fname"> <br><br>
<label for="date"> Enter Birth date:-</label>
<input type="date" id="date"> <br> <br>
<label for"text"> Gender:-</label>
<label for="text">Male</label>
<input type—"radio" id="male" value—"Male">
<label for="text">Female</label>
<input type="radio" id="female" value="Female">
<label for="text">Others</label>
<input type="radio" id="others" value="Others">
<br><br>
<input type="submit">
<input type="reset">
</from>
</body>
</html>
Registration From
Enter full Name:
Email id:
password:
html> <html>
<head> <title>Registration Form</title>
<style> body { background-
color:powderblue;
<style>
</head>
<body>
<form>
<center>
<h2>Sign-up From</h2> <lable>Enter full
Name:</lable> <input type="text"
id="fname"> <br><br>
<lable>Email id:</lable>
<input type="text" id="fname"> <br><br>
<lable>password:</lable>
</body>
</html>
Code:
<html>
<head>
<title>Registration Form</title>
<style> body {
background-
color:powderblue;</style
> </head><body>
•3 Quiz:
1. How do you add a text area to a form?
To add a text area to a form in HTML, the <textarea> element is used.
<form>
<label for="message">Message:</label>
<textarea id="message" name="message" rows= "4 " cols="50"></textarea> </form>
2. What attribute do you set to limit the number of letters in a text field?
To limit the number of characters in a text field in HTML, the maxlength attribute is used.
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" maxlength="20">
PRACTICAL - 3
Exercise:
l. Design a webpage for a NEWS site using an HTML tag DIV that includes positioning
margin and padding properties of CSS.
Code:
html>
<html lang="en">
<head>
< title>Breaking News</title>
<style> body { padding: 10px;
margin: 10px; border: 2px
solid black; display: flex;
flex-wrap: wrap;
. cl { text-align: center;
color: red; border: 5px
outset red; width:
100%;
. news-item { flex: 1; margin: 3px; max-width: calc (50% 2Øpx) ; / * Set maximum width
to 50% of the container minus margins * /
. red-button {
background-color: red;
color: white; padding:
10px 20px; border:
none; border-radius:
5px; text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
< / style>
</head>
<hl class='
<div class="news-item">
<img src="https://tse4.mm.bing.net/th?id=OIP.7-
<div class="news-item">
<img
src="https://tse1.mm.bing.net/th?id=OIP.300RpMSht1uHbewpVdKuwHaE8&pid=Api&P=0&h=1
8Ø" alt="Accident" width="75%" height="60%">
<p><span style="color:red; ">15th Accident in the last 3 days</span> in south Delhi, Lorem<br> ipsum
dolor sit amet, consectetur adipisicing el it . .
<button type="button">know more. .</button> </div>
<div class="news-item">
<img src="https://tse4.mm.bing.net/th?id=OIP.7-
">Rainfa11</span> in south
Delhi, Lorem ipsum dolor sit amet, consectetur adipisicing elit. .
<button type="button">know more. .</button> </div>
Output:
BREAKING NEWS
Heavy Rainfall in south Delhi, Lorem ipsum dolor sit Heavy Rainfall in south Delhi, Lorem ipsum dolor sit amet, amet, consectetur adipisicing elit... 15th Accident in the
last 3 days in south Delhi, Lorem consectetur adipisicing elit... ipsum dolor sit amet, consectetur adipisicing elit...
we are live click to join.„ know more..
know more..
LIVE
</style>
</head>
Try Hovering
<div class="box"></div>
</html>
Output:
(before) (after)
3. table cell and link hover effect
<html
<head>
<meta charset="UTF-8">
<td>JS</td>
<tr>
<td>SQL</td>
<td>React</td>
<td>Nodejs</td>
<tr>
<td>Mongodb</td>
<td>Oracle</td>
<td>Expressjs</td>
</table>
Output:
HTML css JS
•• Exercise:
<html
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.O">
<title>Bootstrap Table</title>
<!-- Bootstrap CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<bodp
<div class="container">
<h2>Simple Bootstrap Table</h2>
<table class="table">
<thead>
<th scope="col">lD</th>
<th scope="col">Name</th>
<th scope="col">Age</th>
</thead>
<tr>
<th scope="row">l</th>
<td>John Doe</td>
<td>30</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jane Smith</td>
<td>25</td>
</tr>
<tr>
<th scope="row">3</th>
<td>James Johnson</td>
<td>40</td>
</tr>
</table>
</html>
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap List</title>
</head>
<div class="container">
<h2>Bootstrap List</h2>
<ul class="list-group">
</html>
Bootstrap List
Item I
Item 2
Item 3
Item 4
Item 5
html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Button</title>
</head>
<div class="container">
<h2>Bootstrap Button</h2>
</html>
Bootstrap Button
Primary Button
1. Bootstrap 3 is mobile first?
3. Which class provide a full width container, spanning the entire width of viewport?
In Bootstrap 3, the class .container-fluid provides a full-width container, spanning the
entire width of the viewport.
</scri
</html>
C G) File I C:/Users/Admin/Desktop/fibonacci.html
Fibonacci Series:
o
2. Write JavaScript code that displays the text "SAL Education Campus" with increasing
font size in interval of 50ms in blue color. When font size reaches to 50px it should
stop. Ans:
<html>
<body style="background-color:#9EDDFF";>
<center>
<div id="h"></div> <script> var v = 0, f =
1,t="SAL Education Campus",color; function a()
setTimeout(a,100);
c();
</script>
</center>
</html>
SAL Education Campus
<head>
<title>URL Validation</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<center>
<h3> URL Validator</h3>
<input type="text" id="urllnput" placeholder="Enter a URL">
<button onclick="checkURL()">Check URL</button>
id="result"></p>
</center>
<script> function
isValidURL(url) {
// Regular expression for a simple URL pattern (http/https/ftp/ftps)
const urlPattern = /A (https? I ftp I ftps):\/\/\S+$/i;
return urlPattern.test(url);
if (isValidURL(inputURL)) {
resultElement.innerText = "Valid URL";
} else { resultElement.innerText = "Invalid
URL";
</script>
</html>
URL Validator
Valid URL
4. Write a JavaScript program that work as a trim function (string) using regular
expression. Ans:
html>
<center>
<h2>Trim Function</h2>
<input type="text" id="inputString" placeholder="Enter a string with spaces">
<button onclick="trimString()">Trim</button>
id="trimmedResult"></p>
</center>
<script> function
customTrim(inputString) {
// Use a regular expression to remove leading and trailing whitespace return
I \S+$/g,
</script>
</html>
Trim Function
Rohit Sharma
5. Write a JavaScript function to check whether a given value is IP value or not. Ans:
html>
<head>
<title>lP Address Validator</title>
<script> function validatelP() { var ipAddress =
document.getElementByld('ipAddress').value;
var pnode=document.getElementByld("res"); if
(ipPattern.test(ipAddress)) {
pnode.textContent="lP Address is Valid. ";
</script>
</head>
<center>
<h1>lP Address Validator</hl>
<form>
<label for="ipAddress">Enter IP Address:</label>
<input type="text" id="ipAddress" name="ipAddress" required>
<button type="button" onclick="validatelP()">Validate</button>
</form> id="res"></p>
</center>
</body>
</html>
IP Address Validator
Enter IPAddress: 192.188.455.255
Address is
Quiz:
1. Inside which HTML element do we put the JavaScript?
Ans: JavaScript code is placed inside the <script> element in HTML.
2. How do you write "Hello World" in an alert box? Ans: To display "Hello World" in an alert box
use syntax World");
5. Which operator is used to assign a value to a variable? Ans: The assignment operator in
JavaScript is z.
6. Is JavaScript case-sensitive?
Ans: Yes, JavaScript is case-sensitive.
return isValid;
</script>
</body>
</html>
Output:
Validation Form
Name: John
2. Design a login form using HTML & JavaScript with following validations on
• username and password fields.
• Password length must be 6 to 12 characters
• Username should not start with _, @ or number. • Phone number must be 10 digit
start with 6/7/8/9
Ans:
if { alert("Username is invalid. It
should not start with @, , or a number."); return false;
if (!password.match(passwordPattern)) {
alert("Password must be 6 to 12 characters long.
"); return false;
</script>
</head>
<body>
<center style="border:2px solid black; padding:20px; width:500px; margin: 100px
450px;
<h2>Login Form</h2>
<form onsubmit="return validateForm()">
Output :
X Login Form
ons%20(1),html
Login Form OK
Usemame:
Password:
PhoneNo
Login
Quiz:
1. How to use external JavaScript file?
Ans: To use an external JavaScript file:
Create a js file with your JavaScript code.
Link it in your HTML with <script src="filename.js"> </script>
You can now use the JavaScript functions and variables in your HTML.
2. What is the working of timers in JavaScript?
Ans: Timers in JavaScript are functions that schedule code execution at specific times
or intervals. setTimeout runs code once after a delay setlnterval runs code repeatedly
at regular intervals, and requestAnimationFrame is used for smooth animations.
3. How can you convert the string of any data base to an integer in Javascript?
Ans: You can convert a string to an integer in javascript using parselnt() or Number().
These data types cover the essentials for working with JavaScript.
ABA
ABCBA ABCDCBA Ans :
<?php
$height = 4; // Change the height of the triangle as needed for ($i — 0; $i
Output:
ABA
ABCBA ABCDCBA
$number = 5;
Output:
Factorial of 5 is 120
Ans:
function isArmstrongNumber($number) {
$numStr = (string)$number;
$numDigits = strlen($numStr);
$sum — 0;
for ($i = 0; $i < $numDigits; $i++) {
$digit — (int)$numStr[$i];
$sum += pow($digit, $numDigits);
$numberl = 153;
$number2 370; $number3 = 371;
Ans:
$numberl = 121;
$number2 = 12321; $number3 — 45678;
if METHOD"] "POST") {
<label f0F"password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
C CD localhosVanswerS.php
Login
Username:
password:
Login
6. Design an html form which takes username and password from user and validate
against stored username and password in file.
Ans:
Index.html
html>
<html>
<head>
<title>Login Form</title>
</head>
<body>
<h2>Login Form</h2>
<form action="validate.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
validate.php
if METHOD"] "POST") {
$username — $ POST ["username"];
$password = $ POST ["password"];
C C) localhost,ftndex.html
Login Form
Username: shailendra
Password:
Login
localhost/validate.php
C (D localhost/validate.php Login
successful!
Ans:
<?php
$startDate = isset($_POST['start date']) ? $ POST['start_date'] : null;
$endDate isset($ POST['end date']) ? $ : null;
$backgroundColor if ($startDate &&
$endDate) { $startTimestamp =
strtotime($startDate); $endTimestamp
strtotime($endDate);
html>
<html>
<head>
<title>Date Difference</title>
</head>
<body>
<h2>Calculate Date Difference</h2>
<form method="post" action="<?php echo $ SERVER['PHP SELF']; ?>">
<label for="start date">Start Date:</label>
<input type="date" id="start date" name="start date" required><br><br>
<?php endif;
</html>
End Date:
Calculate
End Date:
Calculate
Quiz :
1. All variables in PHP start with which symbol?
In PHP, all variables start with the dollar symbol ($) symbol.
Username: Virat
Password:
Keep me logged in
Login
2. Write a php script for setting and retrieving your name and email address using cookies.
->INPUT:
set cookies.html
< ! DOCTYPE html >
<html>
<head>
< title>Set
</head>
<body>
<h2>Set Name and Email</h2>
< form method="post" action=" set set .php">
< label for=" name " >Name : < / label >
< input " " name " name=" name " required><br><br>
show_cookies.php
<head>
< title>Set Cookies</title>
</head>
<body>
<h2>Set Name and Email</h2>
< form method="post" action=" set set .php">
< label for=" name " >Name : < / label >
< input type=" text" id=" name" name=" name " required><br><br>
NAME- SAIYED MOHAMMADSADAB
ENROLMENT: 211260107010
< label for=" email ">EmaiI
<input type="text" id=" email" name=" email " required><br><br>
</body> </html>
setset.php
< ?php if ($ SERVER ["REQUEST METHOD"] - " POST" )
$ name = $ POST ["name"] ;
$ email S POST ["email"] ;
// Set cookies to store name and email setcookie ("user name" ,
$name, time ( ) + 60 * 60 * 24 * 30,
Output :
f.- (D localhost/set-cookies/set_cookies.html
Set Name and Email
ame: Virat
Set
Cookies
3.Perform login to logout session handling. None logged in users can not access the page.
->INPUT:
Login.html
dashboard. php
<head>
< title>Dashboard</titIe>
</head>
<body>
<h2>We1come, <?php echo $username; ?>!</h2>
<p>This is the dashboard. Only logged—in users can access this page.</p>
<a href=" logout .
</body> < / html >
logout . php :
< ?php session start ( ) ;
Loginphp . php :
< ?php session start () ;
Output :
(D localhost,/loggedout/login.html
Login
Username: virat
password:
Login
C O localhost/loggedout/dashboard.php
Welcome, virat!
This is the dashboard. Only logged-m users can access
this page.
->INPUT:
localhost/time.php
5.Write a php code to upload file on server and display file details on the page (ex. file name,
extension,file size)
->INPUT:
Index . html
Upload. php
C G) localhost/index.html CD
Upload a File
1 r.50
@ Q)) ENG
Type here to search 23-10-2023
6. Create a web page which shows the use of Session. (Create, Retrieve, Modify Delete and Destroy
Session Variables)
->INPUT:
Output :
Session Example
Username: Set Session Modify Session Delete Session Destroy Session
Session Data: shailendra
QUIZ:
1. Perform complete user registration i.e. signup, display, update and delete in php.
->INPUT:
regi s tration . php
[ 'user' ] - $ username;
<label
< input for=" email " >EmaiI : < /
required><br><br> label > type=" email" name="
email "
< input
required><br><br> for="password " >Pas sword : < /
label > type="password"
< inputname="password"
value=" Register" >
< / fo rm>
</body> type=" submit" name=" register"
< / html >
Profile . php
< ?php session start ( ) ; if ( !isset ($
SESSION [ 'user' ] ) ) header ( "Location :
registration .php") ; exit () ;
Output:
Sign up
Username: virat
Email: [email protected]
Password:
Register
C G) localhost/registration/profile.php
Welcome, virat!
This is your user profile.
2. Write a php code to check whether the given username is already in the "login_tbl" table or not and
display an appropriate message. ->INPUT:
< ?php
$ servername = " local host" ;
$username = "root" ;
$password — $database —
Output :
3. Write a PHP Calculator class which will accept two values as arguments, then add them, subtract
them, multiply them together, or divide them on request
->INPUT:
/ / Usage
$calculator — new Calculator (10, 5 ) ;
locath0WCakulator.php
CD
(D localhost/Calculator.php
Addition: 15
Subtraction: 5
Multiplication: 50
Division: 2
QUIZ:
1. Create your own jQuery AJAX form having a submit button with validation feature
Code :
Index.html
html>
<html>
<head>
<title>jQuery AJAX Form</title>
<script src="https://code.jquery.com/jquery-3.6.O.min.js"></script>
<script src="script.js"></script> </head>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br><br>
</html>
Script.js
$(document).ready(function() {
$('#myForm').submit(function(e) {
e.preventDefault();
// Client-side validation (you should use more robust validation in production) var
name = var email = $('#email').val();
Output :
jQueryAJAX Form
(D
Name:
Email: [email protected]
Submit
Code :
Index.html
html>
<html>
<head>
<title>Email Validation</title>
<script src=" https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<h2>Email Validation</h2>
<input type="text" id="emaillnput" placeholder="Enter your email">
<button id="validateButton">Validate</button> id="validationMessage"></p>
</body>
</html>
Script.js
$(document).ready(function() {
$('#validateButton').click(function() { var email =
Output :
EmailValidation
C) localhost/lndex.html
Email Validation
p
3. Write a code of jQuery AJAXload content of selected element from a file.
Code :
html>
<html>
<head>
<title>Load Content with jQuerY</title>
<script src="https://code.jquery.com/jquery-3.6.O.min.js"></script> <script >
$(document).ready(function() {
$('#contentSelector').change(function() { var selectedFile =
$(this).val();
$('#loadedContent').load(selectedFile);
</script>
</head>
QUIZ:
3. What are the real web applications of AJAX currently running in the market? AJAX is used in real
web applications for features like dynamic content loading, real-time updates on social media,
web-based email, e-commerce, maps, collaboration tools, weather apps, and online chat. These
applications leverage AJAX to provide a seamless and interactive user experience.