Manual of Web Programming
Manual of Web Programming
Laboratory Manual
Year: 2024-2025
Prepared By
THEORY:
• HTML stands for Hyper Text Markup Language.
• It is used to design web pages using hypertext and markup language.
• Hypertext defines the link between the web pages and markup language defines the
text document within the tag that define the structure of web pages.
• HTML is used to create the structure of web pages that are displayed on the World
Wide Web (www).
• The basic structure of an HTML page is laid out below. It contains the essential
building-block elements (i.e. doctype declaration, HTML, head, title, and body
elements) upon which all web pages are created.
HTML TAGS:
• <html> – This tag is used to define the root element of HTML document. This tag
tells the browser that it is an HTML document. It is the second outer container
element that contains all other elements within it.
• <head> – This tag is used to define the head portion of the HTML document that
contains information related to the document. Elements within the head tag are not
visible on the front-end of a webpage.
• <body> – The body tag is used to enclose all the visible content of a webpage. In
other words, the body content is what the browser will show on the front end.
• <b> and <strong> - Both tags are used to make the text bold.
• <i> -This tag is used to make the text italic.
• <sup> and <sub> - The <sup> tag is used to subscript a text whereas <sub> tag is
used to subscript a text.
• <u> - This tag is used to underline a text.
• <mark> - This tag is used to highlight a text.
• <img> - This tag is used to add image inside webpage/website.
• <link> - This tag is used to define a link between a document and an external
resource. The link tag is mainly used to external style sheet.
HTML TABLES:
• <table> - This tag is used to define table.
• <tr> - This tag is used to define a row in a table.
• <th> - This tag is used to define a header cell in a table.
• <td> - This tag is used to define a cell in a table.
• Colspan – Allows a single cell to span the width of more than one cell or column.
• Rowspan – Allows a single table cell to span the height of more than one cell or row.
<!DOCTYPE html>
<html>
<head>
<title> Making a normal table </title>
</head>
<body>
<table>
<tr>
<th>Book Name</th>
<th>Author Name</th>
<th>Genre</th>
</tr>
<tr>
<td>The Book Thief</td>
<td>Markus Zusak</td>
<td>Historical Fiction</td>
</tr>
<tr>
<td>The Cruel Prince</td>
<td>Holly Black</td>
<td>Fantasy</td>
</tr>
<tr>
<td>The Silent Patient</td>
<td> Alex Michaelides</td>
<td>Psychological Fiction</td>
</tr>
</table>
</body>
</html>
EXERCISE:
QUIZ:
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
What is a form?
• A form is considered to be a series of questions that use field entries to gather data.
• With that said, there is a wide variety of forms and many functions that each of them
serve.
• Some forms are short and work as a simple means to an end – which is the case with
login or checkout forms.
• Others deal in complex topics and need more questions in order to gather all the
necessary data, such as customer satisfaction surveys or event registration forms.
<!DOCTYPE html>
<html>
<head>
<title>A simple login form</title>
</head>
<body>
<form>
Username:<br>
<input type="text" name="username">
<br>
Email id:<br>
<input type="text" name="email_id">
<br><br>
Output:-
1. Text Field in HTML Forms: The text field is a one-line input field allowing the user
to input text. Text Field input controls are created using the “input” element with a
type attribute having value as “text”.
2. Password Field in HTML Forms: Password fields are a type of text field in which
the text entered is masked using asterisk or dots for prevention of user identity from
another person who is looking onto the screen. Password Field input controls are
created using the “input” element with a type attribute having value as “password”.
3. Radio Buttons in HTML Form: Radio Buttons are used to let the user select exactly
one option from a list of predefined options. Radio Button input controls are created
using the “input” element with a type attribute having value as “radio”.
4. Checkboxes in HTML Form: Checkboxes are used to let the user select one or more
options from a pre-defined set of options. Checkbox input controls are created using
the “input” element with a type attribute having value as “checkbox”.
5. Select Boxes in HTML Forms: Select boxes are used to allow users to select one or
more than one option from a pull-down list of options. Select boxes are created using
two elements which are “select” and “option”. List items are defined within the
select element.
6. Text area in an HTML Form: Text Area is a multiple line text input control which
allows user to provide a description or text in multiple lines. A Text Area input
control is created using the “textarea” element.
7. Reset and Submit Buttons: The Submit Button allows the user to send the form data
to the web server. The Reset Button is used to "reset" the form data and use the
default values.
EXERCISE:
1. Create a Registration form.
2. Create a sign-up form.
3. Create Sign-in form.
QUIZ:
1. How do you add a text area to a form?
2. What attribute do you set to limit the number of letters in a text field?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY: -
What is CSS?
• Cascading Style Sheets, fondly referred to as CSS, is a simply designed language
intended to simplify the process of making web pages presentable.
• CSS allows you to apply styles to web pages.
• More importantly, CSS enables you to do this independent of the HTML that makes
up each web page.
• It describes how a webpage should look: it prescribes colors, fonts, spacing, and much
more.
• CSS lets developers and designers define how it behaves, including how elements are
positioned in the browser.
• CSS stands for Cascading Style Sheets.
• CSS describes how HTML elements are to be displayed on screen, paper, or in other
media.
• CSS saves a lot of work. It can control the layout of multiple web pages all at once
• External stylesheets are stored in CSS files.
COLORS: -
The color system used when producing colors by light (RGB)
The color system used when printing (CMY)
The color system used by artist and painters (RYB)
BOX MODEL
In CSS, the term "Box Model" is used when talking about design and layout. The CSS box
model is essentially a box that wraps around every HTML element. It consists of: margins,
borders, padding, and the actual content.
BORDER: -
CSS border properties allow us to set the style, color, and width of the border.
Note: Different properties can be set for all the different borders i.e. top border, right border,
bottom border, and left border.
Properties of CSS Borders:
1. Border Style
CSS border-top style Property
border-right-style Property
border-bottom-style Property
border-left-style Property
2. Border Width
border-top-width Property
border-right-width Property
border-bottom-width Property
border-left-width Property
3. Border Color
border-top-color Property
border-right-color Property
border-bottom-color Property
border-left-color Property
MARGIN: -
The margin property is a shorthand property having the following individual margin
properties:
margin-top: It is used to set the top margin of an element.
PADDING:-
The padding CSS shorthand property can be used to specify the padding for each side of an
element in the following order:
padding-top: It is used to set the width of the padding area on the top of an element.
padding-right: It is used to set the width of the padding area on the right of an element.
EXERCISE:
1. Design a webpage for a NEWS site using an HTML tag DIV that includes positioning
margin and padding properties of CSS.
2. Design an HTML+CSS page to understand the concept of pseudo classes.
3. Design a HTML page using CSS that changes the color of the table cells on mouse
hover. It should also change the colors of the link. (Default link/ link on mouse hover
and visited link).
QUIZ:
1. What does CSS stand for?
2. Which HTML tag is used to define an internal style sheet?
3. Which CSS property is used to change the text color of an element?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY: -
What is bootstrap?
• Bootstrap is a free front-end framework for faster and easier web development.
• Bootstrap includes HTML and CSS based design templates for typography, forms,
buttons, tables, navigation, modals, image carousels and many other, as well as
optional JavaScript plugins.
• Bootstrap also gives you the ability to easily create responsive designs.
• Easy to use: Anybody with just basic knowledge of HTML and CSS can start using
Bootstrap
• Responsive features: Bootstrap's responsive CSS adjusts to phones, tablets, and
desktops
BOOTSTRAP FORMAT:-
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3>Column 1</h3>
<p>Loremipsum dolor..</p>
</div>
<div class="col-sm-4">
<h3>Column 2</h3>
<p>Loremipsum dolor..</p>
</div>
<div class="col-sm-4">
<h3>Column 3</h3>
<p>Loremipsum dolor..</p>
</div>
</div>
</div>
Wrap labels and form controls in <div class="form-group"> (needed for optimum spacing)
Add class. form-control to all textual <input>, <textarea>, and <select> elements
GRID CLASSES: -
The classes above can be combined to create more dynamic and flexible layouts.
EXERCISE:
1. Create a simple table with Bootstrap.
2. Create a list with Bootstrap.
3. Create buttons with Bootstrap.
QUIZ: -
1. Bootstrap 3 is mobile-first?
2. Which class provides a responsive fixed width container?
3. Which class provides a full width container, spanning the entire width of the
viewport?
4. The Bootstrap grid system is based on how many columns?
5. Which class adds zebra-stripes to a table
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
What is JAVASCRIPT?
• JavaScript is a cross-platform, object-oriented scripting language used to make
WebPages interactive (e.g. having complex animations, clickable buttons, popup
menus, etc.).
• There are also more advanced server side versions of JavaScript such as Node.Js
which allow you to add more functionality to a website than simply downloading
files (such as real time collaboration between multiple computers).
• Inside a host environment (for example, a web browser), JavaScript can be
connected to the objects of its environment to provide programmatic control over
them.
• JavaScript could be simply written at the head or bodyportion.
Syntax:
<script type=‖text/javascript‖>
</script>
Variable Declaration:
var x = 10;
var y = ‗hello‘;
to print the message : document.write(‗message body‘)
<!DOCTYPE html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function calculate(form) {
varnum=parseInt(form.number.value); if (isNaN(num) || num< 0) {
form.result.value=(form.number.value + " is not a valid number!
Try again!");
}
if (num == 1 || num == 2) { form.result.value=(num + " is
prime!");
}
for (var i=2;i<num;i++) { if (num % i == 0) { var prime="yes";
form.result.value=(num + " is not prime. It is divisible by " +
i + "."); break;
}
if (num % i != 0) var prime="no";
}
if (prime == "no") form.result.value=(num + " is prime!");
}
</SCRIPT>
</head>
<body>
<center>
<form name=form>
<h2>Prime Number Calculator</h2><p> Please enter a number:<br>
<input type=text name=number size=7>
<input type=button value="Calculate"
onClick="calculate(this.form)">
<P>
<input type=text name=result size=45 value="">
</form>
</center>
</body>
</html>
EXERCISE:
1. Write a JavaScript program that prints first n Fibonacci numbers. Here n will be inserted
by the user.
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.
3. Write a JavaScript function to check whether a given value is an valid url or not
4. Write a JavaScript program that work as a trim function (string) using regular
expression.
5. Write a JavaScript function to check whether a given value is IP value or not.
QUIZ:
1. Inside which HTML element do we put the JavaScript?
2. How do you write "Hello World" in an alert box?
3. How do you create a function in JavaScript?
4. How do you round the number 7.25, to the nearest integer?
5. Which operator is used to assign a value to a variable?
6. Is JavaScript case-sensitive?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
• It is important to validate the form submitted by the user because it can have
inappropriate values. So, validation is must to authenticate user.
• JavaScript provides facility to validate the form on the client-side so data processing
will be faster than server-side validation. Most of the web developers prefer
JavaScript form validation.
• Data validation is the process of ensuring that user input is clean, correct, and useful.
• Typical validation tasks are:
o Has the user filled in all required fields?
o Has the user entered a valid date?
o Has the user entered text in a numeric field?
• Validation can be defined by many different methods, and deployed in many different
ways.
• Server-side validation is performed by a web server, after input has been sent to the
server.
• Client-side validation is performed by a web browser, before input is sent to a web
server.
Syntax:
Email Validation:
Cannot be blank:
Function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out"); return false;
}
}
1. Basic Validation: This warrants that all the mandatory fields are filled. It would require
just a loop through each field in the form and check for data.
2. Data Format Validation: Data validation checks the data for its correctness. Your code
must include appropriate logic to test the accuracy of data.
3. Empty field validation :
<formname="contact_form"method="post"action="/cgi-bin
in/articles/development/javascript/form-validation-with-
javascript/contact_simple.cgi" onsubmit="return validateform();">
return valid;
EXERCISE:
1. Perform complete form validation name, email, phone number, checkbox etc using
JavaScript.
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
QUIZ:
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
PHP: Introduction
• PHP started out as a small open source project that evolved as more and more
people found out how useful it was.
• RasmusLerdorf unleashed the first version of PHP way back in 1994.
• PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
• PHP is a server-side scripting language that is embedded in HTML.
• It is used to manage dynamic content, databases, session tracking, even build
entire e-commerce sites.
• It is integrated with a number of popular databases, including MySQL, PostgreSQL,
Oracle, Sybase, Informix, and Microsoft SQL Server.
SYNTAX:
<?php
//code
?>
Variable declaration:
<?php
$a = “abc”;
$b=123;
echo $a; // Print variable value
echo “second variable:” .$b; // concatenation with .
?>
EXERCISE:
1. Write a PHP program to print alphabet triangles.
A
ABA
ABCBA
ABCDCBA
2. Write a PHP program to print the factorial of a number.
3. Write a PHP program to check Armstrong numbers.
4. Write a PHP program to check palindrome numbers.
QUIZ:
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
What is a Session?
• A session is a global variable stored on the server.
• Each session is assigned a unique id which is used to retrieve stored values.
• Whenever a session is created, a cookie containing the unique session id is stored on
the user’s computer and returned with every request to the server.
• If the client browser does not support cookies, the unique php session id is displayed
in the URL
• Sessions have the capacity to store relatively large data compared to cookies.
CREATING SESSION:
<?php
if(isset($_SESSION['page_count']))
{
$_SESSION['page_count'] += 1;
}
else
{
$_SESSION['page_count'] = 1;
}
echo 'You are visitor number ' . $_SESSION['page_count'];
?>
DESTROYING SESSION:
<?php
session_destroy(); //destroy entire session
?>
<?php
unset($_SESSION['product']); //destroy product session item
?>
cookies.
• Tracking the pages visited by a user
SET COOKIE:
<?php
setcookie(cookie_name, cookie_value, [expiry_time], [cookie_path],
[domain], [secure], [httponly]);
?>
RETRIVE VALUE:
<?php
print_r($_COOKIE);//output the contents of the cookie array variable
?>
DELETE COOKIE:
<?php
setcookie("user_name", "AIT",time() - 360,'/');
?>
EXERCISE:
1. Perform keep me logged checkbox checked using cookie.
2. Write a php script for setting and retrieving your name and email address using
cookies.
3. Perform login to logout session handling. None logged in users cannot access the
page.
4. Write a php program to greet the user based on time.
5. Write a php code to upload file on server and display file details on the page (ex. file
name, extension, file size)
6. Create a web page which shows the use of Session. (Create, Retrieve, Modify Delete
and Destroy Session Variables)
QUIZ:
1. How do you create a cookie in PHP?
2. What is the purpose of $_SESSION []?
3. What is the default execution time set in set_time_limit()?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
THEORY:
• CRUD is an acronym for Create, Read, Update, and Delete. As the name suggests,
these operations manipulate data in a database that is important to any web
application’s basic functionality. We can create a PHP application coupled with a
MySQL database to perform these operations.
<div class="input-group">
<label>Address</label>
<input type="text" name="address" value="">
</div>
<div class="input-group">
<button class="btn" type="submit"
name="save">Save</button>
</div>
</form>
</body>
</html>
EXERCISE:
1. Perform complete user registration i.e. signup, display, update and delete in php.
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.
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
QUIZ:
1. Can I run several versions of PHP at the same time?
2. Can echo in php accept more than 1 parameter?
3. What is the actually used PHP version?
4. How do you execute a PHP script from the command line?
5. What is the main difference between require() and require_once()?
6. How is it possible to set an infinite execution time for PHP script?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)
TITLE: Create a Basic Program that demonstrates the use of AJAX and
JQuery.
OBJECTIVES: On completion of this experiment students will be able to…
• Understanding the concepts of AJAX and jQuery
THEORY:
What is AJAX?
• AJAX = Asynchronous JavaScript and XML.
• In short, AJAX is about loading data in the background and displaying it on the
webpage, without reloading the whole page.
• Examples of applications using AJAX: Gmail, Google Maps, Youtube, and Facebook
tabs.
What is jQuery?
<label>Website</label>
<input type="url" name="website" />
<input type="submit" name="submit" value="Submit Form" />
<div id="server-results">
<!-- For server results -->
</div>
</form>
• The jQuery snippets below demonstrate different ways to make Ajax requests.
$("#my_form").submit(function(event){
event.preventDefault();
//prevent default action
var post_url = $(this).attr("action");
//get form action url
var request_method = $(this).attr("method");
//get form GET/POST method
var form_data = $(this).serialize();
//Encode form elements for submission
$.ajax({
url :post_url,
type: request_method,data : form_data
}).done(function(response)
{ //
$("#server-results").html(response);
});
});
• The .serialize() method serializes a form input to a query string that could be sent
using Ajax.
• HTML Multipart/form-data Form Submit
$("#my_form").submit(function(event){
event.preventDefault();
//prevent default action
var post_url = $(this).attr("action");
//get form action url
var request_method = $(this).attr("method");
//get form GET/POST method
var form_data = new FormData(this);
//Creates new FormData object
$.ajax({
url :post_url,
type: request_method,
data :form_data,
contentType: false,
cache: false,
processData:false
}).done(function(response){ //
$("#server-results").html(response);
});
});
EXERCISE:
1. Create your own jQuery AJAX form having a submit button with validation feature.
2. Write a code to validate user input using jQUERY.
3. Write a code of jQuery AJAXload content of selected element from a file.
QUIZ:
1. Is jQuery a library for client scripting or server scripting?
2. Is it possible to use jQuery together with AJAX?
3. What are the real web applications of AJAX currently running in the market?
4. What are the technologies used by AJAX?
5. What are the features of jQuery?
EVALUATION:
Problem Analysis Understanding Timely Mock Total
& Solution Level Completion
(3) (3) (2) (2) (10)