WP Lab Manual
WP Lab Manual
DEVANSHI DAVE
Index
Create your resume using HTML (Suggested sections of resume are Personal
Information, Educational Information, Professional Skills, Experience,
1. Achievements, Hobbies),
Experiment with text, colors, link and lists.
Create your class time table using table tag, experiment with rowspan,
2. colspan,
cellspacing and cellpadding attributes.
Design static web pages for your college containing a description of the courses,
departments, faculties, library etc. Provide
3.
links for navigation among pages.
Design a web page of your home town with an attractive background color, text
4. color, an
Image, font etc. (use internal CSS).
Use Inline CSS to format your resume that
5.
you created in practical no 01.
Use External, Internal, Inline CSS to format
6. College Web site that you created in Practical No.03
1
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 1
Create your resume using HTML (Suggested sections of resume are Personal
Information, Educational Information, Professional Skills, Experience,
Achievements, Hobbies), Experiment with text, colors, link and lists.
Date:
Relevant CO: 1
Objectives:
Theory:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1> Hello World </h1>
</body>
</html>
DOCTYPE specifies the document type. the document type is specified by the Document Type
Definition (DTD).
- <head> section is used to specify title of the page using <title> tag. It is also used for
adding external css and javascript files to html document.
2
Web Programming (3160713) PROF. DEVANSHI DAVE
- Editors like notepad, notepad++, sublime text, visual studio code can be used to write html
code
- Save html document file with .html extension
- To check output open html document with browser like google chrome, Microsoft edge,
Firefox etc.
HTML Formatting Tags
- HTML List allow web developers to group a set of related items in lists
o Starts with <ul> tag list item starts with <li> tag
o Lists items will be marked with bullets
o Example
<ul>
<li>C</li>
<li>C++</li>
<li>Java</li>
</ul>
3
Web Programming (3160713) PROF. DEVANSHI DAVE
o Starts with <ol> tag. Each list item starts with the <li> tag.
o Lists items will be marked with numbers by default
<ol>
<li>Apple</li>
<li>Mango</li>
<li>Banana</li>
</ol>
<dl>
<dt>CE</dt>
<dd>- Computer Engineering</dd>
<dt>IT</dt>
<dd>- Information Technology</dd>
</dl>
o <dl> tag defines the description list,<dt> tag defines the term (name) <dd> tag
describes each term
4
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 2
Create your class time table using table tag, experiment with rowspan, colspan,
cellspacing and cellpadding attributes.
Date:
Relevant CO: 1
Objectives:
- HTML tables allow web developers to arrange data into rows and columns.
- The <table> tag defines an HTML table.
- table row is defined with a <tr> tag.
- table header is defined with a <th> tag.
- text in <th> elements are bold and centered.
- Each table data/cell is defined with a <td>.
- By default, the text in <td> elements are regular and left-aligned.
- colspan attribute is used to make a cell span more than one column.
- Rowspan attriute is used to make a call span more than one row.
- cellpadding represents the distance between cell borders and the content within a cell.
- The cellspacing attribute defines space between table cells.
- Example
o Below code is for arranging car details in tabular format.
o You may study table tag and output as below.
5
Web Programming (3160713) PROF. DEVANSHI DAVE
Code Output
<table border="1">
<tr>
<th>Name</th>
<th>Color</th>
<th>Price</th>
</tr>
<tr>
<td>Swift VXI</td>
<td>Red</td>
<td>800000</td>
</tr>
<tr>
<td>Vagon R</td>
<td>White</td>
<td>600000</td>
</tr>
</table>
6
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 3
Design static web pages for your college containing a description of the courses,
departments, faculties, library etc. Provide links for navigation among pages.
Date:
Relevant CO: 1
Objectives:
Theory:
HTML Links:
7
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 4
Design a web page of your home town with an attractive background color,
text color, an Image, font etc. (use internal CSS).
Date:
Relevant CO: 1
Objectives:
Theory:
Introduction To CSS
Example: In this example all <p> elements will be center-aligned, with a red text color
Code Output
8
Web Programming (3160713) PROF. DEVANSHI DAVE
<!DOCTYPE html>
<html>
<head>
<style>
p{
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>These paragraphs are styled
with CSS.</p>
</body>
</html>
- p is a selector in CSS (it points to the HTML element you want to style: <p>).
- color is a property, and red is the property value
- text-align is a property, and center is the property value
CSS Selectors
p{
text-align: center;
color: red;
}
9
Web Programming (3160713) PROF. DEVANSHI DAVE
<!DOCTYPE html>
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by
the style.</p>
</body>
</html>
o The class selector selects HTML elements with a specific class attribute.
o To select elements with a specific class, write a period (.) character, followed by
the class name.
o Example
▪ In this example all HTML elements with class="center" will be red and
center-aligned:
<!DOCTYPE html>
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1 class="center">Red and center-
aligned heading</h1>
<p class="center">Red and center-
aligned paragraph.</p>
</body>
</html>
o The universal selector (*) selects all HTML elements on the page.
o Example
-
10
Web Programming (3160713) PROF. DEVANSHI DAVE
<!DOCTYPE html>
<html>
<head>
<style>
*{
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1>Hello world!</h1>
<p>Every element on the page will be
affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
o The grouping selector selects all the HTML elements with the same style
definitions.
o To group selectors, separate each selector with a comma.
o Example:
h1, h2, p {
text-align: center;
color: red;
}
o Some selectors can be considered different because of the way the element they
belong to works.
o For example, the anchor that creates a link between documents can have pseudo
classes attached to it simply because it is not known at the time of writing the
markup what the state will be.
o It could be visited, not visited, or in the process of being selected.
o CSS pseudo-classes are used to add special effects to some selectors. You do not
need to use JavaScript or any other script to use those effects.
o selector: pseudo-class {property: value}
o CSS classes can also be used with pseudo-classes
o selector.class: pseudo-class {property: value}
o Example
11
Web Programming (3160713) PROF. DEVANSHI DAVE
- Types Of CSS
o External CSS
o Internal CSS
o Inline CSS
- Internal CSS
o An internal style sheet may be used if one single HTML page has a unique style.
o The internal style is defined inside the <style> element, inside the head section.
o Example:
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
12
Web Programming (3160713) PROF. DEVANSHI DAVE
body {
background-color: lightblue;
}
<h1 style="color:Tomato;">Hello
World</h1>
13
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 5
Use Inline CSS to format your resume that you created in practical no 01.
Date:
Relevant CO: 1
Objectives:
Internal CSS
- An inline style may be used to apply a unique style for a single element.
- To use inline styles, add the style attribute to the relevant element. The style attribute can
contain any CSS property.
Example:
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-align:center;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>
14
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 6
Use External, Internal, Inline CSS to format College Web site that you created
in Practical No.03
Date:
Relevant CO: 1
Objectives:
External CSS
• An external file is a good idea when you have a number of pages, or even a complete site,
which you need to control in terms of presentation.
• it saves lots of effort as at one time you would have needed to alter each page individually.
• With an external style sheet, you can change the look of an entire website by changing just
one file!
• Each HTML page must include a reference to the external style sheet file inside the <link>
element, inside the head section.
• External CSS file must be saved with a .css extension.
• Example
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
type="text/css" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
15
Web Programming (3160713) PROF. DEVANSHI DAVE
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
16
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 7
Date:
Relevant CO: 2
Objectives:
Javascript
o Internal Javascript
▪ JavaScript code is placed in the head and body section of an HTML page.
▪ Example
<html>
<head>
<title>Internal JavaScript</title>
<script type="text/javascript">
document.write("Hello World.!!!");
</script>
</head>
<body>
</body>
</html>
o External JavaScript
▪ If you want to use the same script on several pages it could be good idea to
place the code in separate file, rather than writing it on each.
▪ JavaScript code are stored in separate external file using the .js extension
(Ex: external.js).
17
Web Programming (3160713) PROF. DEVANSHI DAVE
▪ Example:
HTML File : index.html
<html>
<head>
<title>External JavaScript</title>
<script type="text/javascript" src="external.js"></script>
</head>
<body>
</body>
</html>
18
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 8
Date:
Relevant CO: 2
Objectives:
Theory:
Javascript Syntax
varx,y,z;
x=5;
y=5
z=x+y;
document.write(“total is : ”+z)
- When a web page is loaded, the browser creates a Document Object Model of the page.
- The HTML DOM model is constructed as a tree of Objects:
- Using DOM Javascript can
o change all the HTML elements in the page
o change all the HTML attributes in the page
19
Web Programming (3160713) PROF. DEVANSHI DAVE
o change all the CSS styles in the page
o remove existing HTML elements and attributes
o add new HTML elements and attributes
o react to all existing HTML events in the page
o create new HTML events in the page
DOM Examples
<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>
</body>
</html>
20
Web Programming (3160713) PROF. DEVANSHI DAVE
Here getElementById is a method, while innerHTML is a property.
<!DOCTYPE html>
<html>
<body>
<h2>Number Validation</h2>
<input id="numb">
<p id="demo"></p>
<script>
function myFunction() {
// Get the value of the input field with id="numb"
let x = document.getElementById("numb").value;
// If x is Not a Number or less than one or greater than 10
let text;
if (isNaN(x) || x < 1 || x > 10) {
text = "Input not valid";
} else {
text = "Input OK";
}
document.getElementById("demo").innerHTML = text;
}
</script>
</body>
</html>
21
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 9
Date:
Relevant CO: 3
Objectives:
PHP
• PHP is a server scripting language, and a powerful tool for making dynamic and
interactive Web pages.
• PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's
ASP.
• Syntax
<?php
// PHP code goes here
?>
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
22
Web Programming (3160713) PROF. DEVANSHI DAVE
Statement Syntax
Statement Syntax
23
Web Programming (3160713) PROF. DEVANSHI DAVE
The PHP for Loop
for (init counter; test
counter; increment
counter) {
code to be executed for
each iteration;
}
The PHP foreach Loop
foreach
($array as $value) {
code to be executed;
}
Conclusion:
The PHP program efficiently checks whether a given number is prime or not using PHP's
conditional statements and loops. This practical exercise enhances understanding of PHP syntax
and its application in solving mathematical problems on the web
24
Web Programming (3160713) PROF. DEVANSHI DAVE
Experiment No: 10
Date:
Relevant CO: 5
Objectives:
What is REST?
REST stands for Representational State Transfer, REST is an architectural style which defines
a set of constraints for developing and consuming web services through standard protocol
(HTTP). REST API is a simple, easy to implement and stateless web service. There is another
web service available which is SOAP which stands for Simple Object Access Protocol which is
created by Microsoft.
REST API is widely used in web and mobile applications as compared to SOAP. REST can
provide output data in multiple formats such as JavaScript Object Notation (JSON), Extensible
Markup Language (XML), Command Separated Value (CSV) and many others while SOAP
described output in Web Services Description Language (WSDL).
How Does REST API Work
REST requests are related to CRUD operations (Create, Read, Update, Delete) in database, REST
uses GET, POST, PUT and DELETE requests. Let me compare them with CRUD.
▪ GET is used to retrieve information which is similar to Read
▪ POST is used to create new record which is similar to Create
▪ PUT is used to update record which is similar to Update
▪ DELETE is used to delete record which is similar to Delete
25
Web Programming (3160713) PROF. DEVANSHI DAVE
A. Create a Database and Table with Dummy Data
B. Create a Database Connection
C. Create a REST API File
A. Create a Database and Table with Dummy Data
To create database run the following query.
To create a table run the following query. Note: I have already attached the SQL file of this table
with dummy data, just download the complete zip file of this tutorial.
26
Web Programming (3160713) PROF. DEVANSHI DAVE
mysqli_close($con);
}else{
response(NULL, NULL, 200,"No Record Found");
}
}else{
response(NULL, NULL, 400,"Invalid Request");
}
function response($order_id,$amount,$response_code,$response_desc){
$response['order_id'] = $order_id;
$response['amount'] = $amount;
$response['response_code'] = $response_code;
$response['response_desc'] = $response_desc;
$json_response = json_encode($response);
echo $json_response;
}
?>
The above script will accept the GET request and return output in the JSON format.
I have created all these files in folder name rest, now you can get the transaction information by
browsing the following URL.
http://localhost/rest/api.php?order_id=15478959
Above URL is not user friendly, therefore we will rewrite URL through the .htaccess file, copy
paste the following rule in .htaccess file.
RewriteEngine On # Turn on the rewriting engine
Now you can get the transaction information by browsing the following URL.
http://localhost/rest/api/15478959
27
Web Programming (3160713) PROF. DEVANSHI DAVE
1. Create an Index File with HTML Form
2. Fetch Records through CURL
1. Create an Index File with HTML Form
<form action="" method="POST">
<label>Enter Order ID:</label><br />
<input type="text" name="order_id" placeholder="Enter Order ID" required/>
<br /><br />
<button type="submit" name="submit">Submit</button>
</form>
$client = curl_init($url);
curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($client);
$result = json_decode($response);
echo "<table>";
echo "<tr><td>Order ID:</td><td>$result->order_id</td></tr>";
echo "<tr><td>Amount:</td><td>$result->amount</td></tr>";
echo "<tr><td>Response Code:</td><td>$result->response_code</td></tr>";
echo "<tr><td>Response Desc:</td><td>$result->response_desc</td></tr>";
echo "</table>";
}
?>
You can do anything with these output data, you can insert or update it into your own database if
you are using REST API of any other service provider. Usually in case of online transaction, the
service provider provides status of payment via API. You can check either payment is made
successfully or not. They also provide a complete guide of it.
Note: Make sure CURL is enabled on your web server or on your localhost when you are
testing demo.
28