0% found this document useful (0 votes)
122 views

Fybscit Div B Roll No 212 Web Programming All Practicals

The document outlines practical assignments for a Web Programming course. It includes 11 practical assignments covering topics like basic HTML tags, image maps, tables, forms, JavaScript, PHP, databases, XML, email and sessions/cookies. Some of the specific tasks mentioned are designing web pages using text formatting tags, creating links between pages, demonstrating different style sheets, creating an image map, validating form controls using JavaScript and sending an email with attachment.

Uploaded by

Vidhan Pawar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Fybscit Div B Roll No 212 Web Programming All Practicals

The document outlines practical assignments for a Web Programming course. It includes 11 practical assignments covering topics like basic HTML tags, image maps, tables, forms, JavaScript, PHP, databases, XML, email and sessions/cookies. Some of the specific tasks mentioned are designing web pages using text formatting tags, creating links between pages, demonstrating different style sheets, creating an image map, validating form controls using JavaScript and sending an email with attachment.

Uploaded by

Vidhan Pawar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 89

FYBSC.

IT DIV:-B ROLL NO:-212

Practical Practical of USIT2P3 


No.  WEB Programming

1.  Use of Basic Tags

a.  Design a web page using different text formatting tags.

b.  Design a web page with links to different pages and allow
navigation  between web pages.

c.  Design a web page demonstrating all Style sheet types.

2.  Image maps (Tables, Forms and Media)

a.  Design a web page with Image maps.

b.  Design a web page demonstrating different semantics

c.  Design a web page with different tables. Design a web page using a
table  so that the content appears well placed.

d.  Design a web page with a form that uses all types of controls.

e.  Design a web page embedding with multimedia features.

3.  Java Script

a.  Using JavaScript design, a web page that prints


factorial/Fibonacci  series/any given series.

b.  Design a form and validate all the controls placed on the form using
Java  Script.

c.  Write a JavaScript program to display all the prime numbers between 1
and  100.

d.  Write a JavaScript program to accept a number from the user and
display  the sum of its digits.

e.  Write a program in JavaScript to accept a sentence from the user and 
display the number of words in it. (Do not use split () function).

f.  Write a javascript program to design a simple calculator.

WEB PROGRAMMING 1
FYBSC.IT DIV:-B ROLL NO:-212

4.  Control and looping statements and Javascript references:

a.  Design a web page demonstrating different conditional statements.

b.  Design a web page demonstrating different looping statements.

c.  Design a web page demonstrating different Core JavaScript 


references (Array, Boolean, Date, Function, Math, Number,  Object,
String, regExp).

5.  Basic PHP I

a.  Write a PHP Program to accept a number from the user and print it 
factorial.

b.  Write a PHP program to accept a number from the user and print
whether it  is prime or not.

6.  Basic PHP II

a.  Write a PHP code to find the greater of 2 numbers. Accept the no.
from the  user.

b.  Write a PHP program to display the following Binary Pyramid: 



0 1 
1 0 1  
0101

7.  String Functions and arrays

a.  Write a PHP program to demonstrate different string functions.

WEB PROGRAMMING 2
FYBSC.IT DIV:-B ROLL NO:-212

b.  Write a PHP program to create one dimensional array.

8.  PHP and Database

a.  Write a PHP code to create: a) Create a database College b) Create a


table Department  (Dname, Dno, Number_of_faculty)

b.  Write a PHP program to create: a) database named “College”. Create a


table named  “Student” with following fields (sno, sname, percentage).
Insert 3 records of your  choice. Display the names of the students
whose percentage is between 35 to 75 in a  tabular format.

c.  Design a PHP page for authenticating a user.

9.  Design an XML document and display it in browser using XSL

10.  Email

a.  Send email with attachment.

11.  Sessions and Cookies

a.  Demonstrate use of sessions and cookies

WEB PROGRAMMING 3
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 1 (a)
Use of Basic Tags
AIM : a)Design a web page using different text formatting tags.

CODE :
<html>

<head>

<title>vidhan_Practical 1a_</title>

</head>

<body>

<p> This is normal Text</P>

<p><i> This is Italic</i></p>

<p><strong> This Text is strong Text </strong></p>

<p> <em> This is Emphasized Text </em></p>

<h2> HTML<small>small</small> Formatting</h2>

<p> This is <sub> subscripted </sub></p>

<p> This is <sup> superscripted </sup></p>

<p> My favourite color is not <del> red</del> it is black </p>

<p> My favourite <ins>color</ins> is black</p>

</body>

</html>

Output:

WEB PROGRAMMING 4
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 1 (b)
AIM: Design a web page with links to different pages and allow navigation between web pages.

CODE FOR 1ST PAGE :

<html>
<head>
<title>vidhan_practical1(b)</title>
</head>
<body> <h2> WELCOME<h2></br>
<strong> Web Navigation Practical</strong></br>
<a href="home.html">Home</a></br>
<div align="center">
WELCOME TO THE HOME PAGE</br>
This is the practical no.1(b) of web navigation
</body>
</html>
Output:-

WEB PROGRAMMING 5
FYBSC.IT DIV:-B ROLL NO:-212

CODE 2ND PAGE :

<html>
<head>
<title>vidhan_Home</title>
</head>
<body>
<div align="center">
<strong>About Environment</strong>
</div>
Environment means anything that surrounds us. </br> It can be living
(biotic) or non-living (abiotic) things. </br> It includes physical,
chemical and other natural forces. </br> Living things live in their
environment. </br> They constantly interact with it and adapt
themselves to conditions in their environment. </br>
<a href="Noisepollution.html">Noise pollution</a>
</body>
</html>
Output:-

WEB PROGRAMMING 6
FYBSC.IT DIV:-B ROLL NO:-212

CODE 3 FOR 3RD PAGE :

<html>
<head>
<title>vidhan_Noise pollution</title>
</head>
<body>
<div align="center">
<strong>About Environment</strong>
</div>
Noise pollution is considered to be any unwanted or disturbing
sound that affects the health and well-being of humans and other
organisms. Sound is measured in decibels. ... </br> Noise pollution
impacts millions of people on a daily basis. </br> The most common
health problem it causes is Noise Induced Hearing Loss (NIHL).</br>
</body>
</html>
Output:-

WEB PROGRAMMING 7
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 1 (C)

Aim:c)Design a web page demonstrating all Style sheet types.

CODE:

<html>
<head>
<title> vidhan_stylesheet</title>
</head>
<style>
body
{bg-color: yellow;
color:grey;
}
h1
{color:maroon;
margin-left:40px;
}
p{font-family:"Algerian";
}
ul.a
{
list-style-type:circle
}
ul.b
WEB PROGRAMMING 8
FYBSC.IT DIV:-B ROLL NO:-212

{
list-style-type:square
}
</style>
<body>
<h1>This is Heading</h1>
<p> List of programming language</p>
<ul class ="a">
<li>HTML</li>
<li>C</li>
<li>java</li></ul>
<ul class ="b">
<li>HTML</li>
<li>C</li>
<li>java</li></ul>
</body>
<html>
Output:-

WEB PROGRAMMING 9
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 2 (a)
Image maps (Tables, Forms and Media)

AIM: a)Design a web page with Image maps.

CODE :

<!DOCTYPE html>
<html>
<head>
<title>vidhan_Imagemap</title>
</head>
<h3>Mapping an Image</h3>

<body>

<p>Click on the different planets of the map to know about


them.</p>

<img src="planets.gif"
usemap="#Solarmap">

<map name="Solarmap">
<area shape="circle" coords="60,60,40" alt="mercury"
href="https://en.wikipedia.org/wiki/Mercury_(planet)">

WEB PROGRAMMING
10
FYBSC.IT DIV:-B ROLL NO:-212

<area shape="circle" coords="177,60,40" alt="venus"


href="https://en.wikipedia.org/wiki/Venus">

<area shape="circle" coords="293,60,40" alt="earth"


href="https://en.wikipedia.org/wiki/Earth">

<area shape="circle" coords="406,65,40" alt="mars"


href="https://en.wikipedia.org/wiki/Mars">

<area shape="circle" coords="60,180,70" alt="jupiter"


href="https://en.wikipedia.org/wiki/Jupiter">

<area shape="circle" coords=" alt="saturn"


href="https://en.wikipedia.org/wiki/Saturn">

<area shape="circle" coords=" alt="uranus"


href="https://en.wikipedia.org/wiki/Uranus">

<area shape="circle" coords=" alt="neptune"


href="https://en.wikipedia.org/wiki/Neptune">

</map>
</body>
</html>
WEB PROGRAMMING
11
FYBSC.IT DIV:-B ROLL NO:-212

Output:-

PRACTICAL NO 2 (b)
AIM: B)Design a web page demonstrating different semantics.

CODE: <!DOCTYPE html>


<html>
<head><title>vidhan pawar2B</title></dead>
<style>
h1 {Color: #006400;
font-size: 50px; Text-align: left;
}
p{
font-size: 15px; text-align:left; margin-top:40px;
}
h3 {
Color: #006400;
font-size: 25px; Text-align:left;
}
</style>
</head>
<body>
<main>
WEB PROGRAMMING
12
FYBSC.IT DIV:-B ROLL NO:-212

<figure>
<img src="times.png" alt="" align="center" style="width: 100%"> <figcaption>TIMES OF
INDIA</figcaption>
</figure>
</main>
<footer>
<article><h3>Maharashtra News Live Updates:</h3>
<aside>
<p>Mumbai will be unlocked by end of this month, says mayor Kishori Pednekar
</p>
</aside>
<p>There is good news for Mumbaikars. Mumbai will be unlocked by the end of this month. We have
made up our minds, but it is essential for the people to wear masks and observe social distancing:
Mumbai Mayor Kishori Pednekar (ANI)
</p>
</article>
<details>
<summary class="GFG">Details</summary>
</br>
<p></br>Mumbai Mayor Kishori Pednekar on Tuesday said the city would be unlocked by the end of
this month. She said, "We have made up our minds, but it is essential for the people to wear masks
and observe social distancing." Stay with TOI for all the latest updates:
</p>
</details>
<p>Posted by:Times of India</p>
<p>Contact: <a href="https://timesofindia.indiatimes.com/city/mumbai/mumbai-news-live-updates-
covid-19-cases-omicron-maharashtra-bmc-pollution-uddhav-thackeray-shiv-sena-8-february-2022/
liveblog/89413105.cms">
<a>Times of india </a>.
</p>
</footer>
</main>
</body>
</html>

WEB PROGRAMMING
13
FYBSC.IT DIV:-B ROLL NO:-212

OUTPUT:-

WEB PROGRAMMING
14
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 2 (c)
AIM:Design a web page with different tables. Design a web pages using table so that the
content appears well placed.

CODE:

<html>
<body>
<div class="one" align="center">
<p>Chikitsak Samuhas's</p>
<p>Sir Sitaram & Lady shamtaramPatkar College of Arts and
Science</p>
<p>and V.P. Varde College Commerce & Economics </p>
<p>An Autonomous college, Affiliated to University of Mumbai </p>
<b><p>F.Y.B.Sc.IT Divison B Semester 2nd YEAR 2021-2022</p></b>
</div>
<head>
<style>
.two table {
background-color:green;
}
</style>
</head>

WEB PROGRAMMING
15
FYBSC.IT DIV:-B ROLL NO:-212

<section>
<div class="two" align="center" >
<table height="100px" width="200px" table border="1px">

<div class="ok">
<tr>
<th>Timing</th>
<th>Monday</th>
<th>Tuesday </th>
<th>Wednesay</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>
</div>
<tr>
<th>8:00 to 8:50</th>
<th>Microprocessor architecture </th>
<th>Microprocessor architecture </th>
<th>green computing</th>
<th>Web programming </th>
<th>Microprocessor architecture</th>
<th> holiday</th>
</tr>
WEB PROGRAMMING
16
FYBSC.IT DIV:-B ROLL NO:-212

<tr>
<th>9:00 to 9:50</th>
<th>Microprocessor architecture</th>
<th>Microprocessor architecture </th>
<th>Numerical and Statistical Methods</th>
<th>Object Oriented Programming </th>
<th>green computing </th>
<th>holiday</th>
</tr>
<tr>
<th>10:10 to 11:00</th>
<th>Web programming</th>
<th>Object Oriented Programming </th>
<th>Object Oriented Programming</th>
<th>Numerical and Statistical Methods</th>
<th>Numerical and Statistical Methods</th>
<th>holiday</th>
</tr>
<tr>
<th>11:30 to 12:20</th>
<th> </th>
<th> </th>
<th>Microprocessor architecture</th>
<th></th>
WEB PROGRAMMING
17
FYBSC.IT DIV:-B ROLL NO:-212

<th> </th>
<th> </th>
</tr>
<tr>
<th>12:35 to 1:25</th>
<th> </th>
<th> </th>
<th>web programming </th>
<th></th>
<th></th>
<th> </th>
</tr>
<tr>
<th>11:30 to 2:00(practical session)</th>
<th>Numerical and Statistical Methods</th>
<th>Web programming </th>
<th> </th>
<th>Object Oriented Programming</th>
<th>Web programming</th>
<th> holiday</th>
</tr>

WEB PROGRAMMING
18
FYBSC.IT DIV:-B ROLL NO:-212

</tr>
</table>

</div>
</body>
</html>
Output:-

WEB PROGRAMMING
19
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 2 (d)
AIM : d)Design a web page with a form that uses all types of controls.

CODE :

<html>
<head>
<title>vidhan practical 2D</title>
</head>
<body bgcolor="white">
<div align="center">
<br>
<h1>Enter Your Personal Information</h1>
<p><i>Creating form practicals</i></p>
</div>
<hr>
<div align="center">
<form>
<table>
<tr>
<td width="100">First Name: </td>
<td width="100"><input type="text"
name="fname"/></td><br><br>
</tr>
<tr>
<td width="100">Last Name: </td>
WEB PROGRAMMING
20
FYBSC.IT DIV:-B ROLL NO:-212

<td width="100"><input type="text"


name="lname"/></td><br><br>
</tr>
<tr>
<td width="100"> Gender: </td>
<td width="100">
<input type="radio" name="gender">Male
<input type="radio" name="gender">Female
</td>
<br><br>
</tr>
<tr>
<td width="100"> Course: </td>
<td width="100">
<select name="course">
<option value="bscit">BScIT</option>
<option value="bcom">BCom</option>
<option value="baf">BAF</option>
<option value="bsccs">BScCS</option>
</select>
</td><br><br>
</tr>
<tr>
<td width="100"> Hobbies:</td>
WEB PROGRAMMING
21
FYBSC.IT DIV:-B ROLL NO:-212

<td width="100">
<input type="radio" name="hobbies">Singing
<input type="radio" name="hobbies">Dancing
<input type="radio" name="hobbies">Playing
cricket
</td>
<br><br>
</tr>
<tr>
<td width="100">Upload your image:</td>
<td width="100">
<input type='file' accept='image/*'></td
<br><br>
</tr>
<tr>
<td width="100">Comments:</td>
<td width="100"><textarea
name="comments" rows="4" cols="50">
Your Comments...
</textarea>
<br><br>
</tr>
</table>
<br>

WEB PROGRAMMING
22
FYBSC.IT DIV:-B ROLL NO:-212

<input type="submit" value="Submit"/>


<input type="reset" value="Reset"/>
</form>
</div>
</body>
</html>
Output:-

WEB PROGRAMMING
23
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL 2E

AIM: Design a web page embedding with multimedia features.

CODE:
<html>
<head>
<title>vidhan practical2E</title>
</head>
<body>

<div id="masthead">
<h1 class="pagetitle">Incorporating Audio and Video Practical</h1>
<h5 class="tagline"><i>Using HTML5 tags</i></h5>
<hr>
</div>

<p><b>Here is an audio!!! </b></p>


<audio controls>
<source src="file_example_MP3_700KB.mp3">
</audio>

<p><b>Here is a video!!! </b></p>


<video src="SampleVideo_360x240_30mb.mkv" autoplay controls>
</video>

</body>
</html>

OUTPUT:-

WEB PROGRAMMING
24
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
25
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 3 (a)
Java Script

AIM : a) Using JavaScript design, a web page that prints factorial/Fibonacci series/any
given series.

CODE :

<html>
<head>
<title>VIDHAN practical3A</title>
</head>
<body>
<br>
<h1>Factorial of number using java script</h1>
<h2>Enter valid number...!</h2>

<input type="number" min="1" id= "num">


<button type="button" onclick="submit()">Submit</button>

<h3> Factorial: <span id= "answer"> </span> </h3>

<script>

function submit(){
var num =
parseInt( document.getElementById("num").value);
WEB PROGRAMMING
26
FYBSC.IT DIV:-B ROLL NO:-212

if( isNaN(num) ){
alert("Enter valid number");
return;
}
var factorial = calcFact(num);
document.getElementById("answer").innerHTML = factorial;
}

function calcFact(num){
var i;
var fact=1;
for(i=1;i<=num;i++){
fact=fact*i;
}
return fact;
}
</script>
</body>
</html>

WEB PROGRAMMING
27
FYBSC.IT DIV:-B ROLL NO:-212

Output:-

PRACTICAL NO 3 (b)
AIM : b) Design a form and validate all the controls placed on the form using Java  Script.

CODE :
<html>
<head>
<title>vidhan_PRAC3B </title>
<script>

function Validation () {
var name = document.forms["RegForm"]["Name"];
var email = document.forms["RegForm"]["EMail"];
var phone = document.forms["RegForm"]["Telephone"];
var what = document.forms["RegForm"]["Subject"];
var password = document.forms["RegForm"]["Password"];
var address = document.forms["RegForm"]["Address"];

if (name.value == "") {
window.alert("Please enter your name.");
WEB PROGRAMMING
28
FYBSC.IT DIV:-B ROLL NO:-212

name.focus();
return false;
}

if (address.value == "") {
window.alert("Please enter your address.");
address.focus();
return false;
}

if (email.value == "") {
window.alert(
"Please enter a valid e-mail address.");
email.focus();
return false;
}

if (password.value == "") {
window.alert("Please enter your password");
password.focus();
return false;
}

if (phone.value == "") {
WEB PROGRAMMING
29
FYBSC.IT DIV:-B ROLL NO:-212

window.alert(
"Please enter your telephone number.");
phone.focus();
return false;
}

if (what.selectedIndex < 1) {
alert("Please enter your course.");
what.focus();
return false;
}

return true;
}
</script>
</head>
<body>
<h1 style="text-align: center;">REGISTRATION FORM</h1>
<form name="RegForm"
onsubmit="return Validation ()" method="post">
<p>Name: <input type="text"
size="65" name="Name" /></p>
<br />
<p>Address: <input type="text"

WEB PROGRAMMING
30
FYBSC.IT DIV:-B ROLL NO:-212

size="65" name="Address" /></p>


<br />
<p>E-mail Address: <input type="text"
size="65" name="EMail" /></p>
<br />
<p>Password : <input type="password"
min="1" size="65" name="Password"></p>
<br />
<p>Telephone: <input type="text"
size="65" name="Telephone" /></p>
<br />

<p>
SELECT YOUR COURSE
<select type="text" value="" name="Subject">
<option> </option>
<option>BSc(IT)</option>
<option>BBA</option>
<option>BCA</option>
<option>B.COM</option>
<option>MSc(IT)</option>
</select>
</p>

WEB PROGRAMMING
31
FYBSC.IT DIV:-B ROLL NO:-212

<br />
<p>Comments: <textarea cols="55"
name="Comment"> </textarea></p>
<p>
<input type="submit"
value="send" name="Submit" />
<input type="reset"
value="Reset" name="Reset" />
</p>
</form>
</body>
<style>
div {
box-sizing: border-box;
width: 100%;
border: 100px solid black;
float: left;
align-content: center;
align-items: center;
}
form {
margin: 0 auto;
width: 600px;
}
WEB PROGRAMMING
32
FYBSC.IT DIV:-B ROLL NO:-212

</style>
</html>
Output:-

PRACTICAL NO 3 (c)
AIM : c) Write a JavaScript program to display all the prime numbers between 1 and 100.

CODE :
<script>
function checkprimenumber(n)
{
for (c=2; c<=n-1; C++){
if (n%c== 0 ) {
return false;
}
return true;
}
}
WEB PROGRAMMING
33
FYBSC.IT DIV:-B ROLL NO:-212

function printprimenumber (number)


{
if (checkprimenumber (number) == true){
document.write(number+" is Prime Number
<br />");
}
}
function printnumbers(range)
{
for (i=1; i<=range; i++){
printprimenumber(i);
}
}
var maxnumber =100;
printnumbers(maxnumber);
</script>
Output:-

WEB PROGRAMMING
34
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
35
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 3 (d)
AIM : d) Write a JavaScript program to accept a number from the user and display the sum
of its digits.

CODE :
<html>
<body>
<h1>JS Sum of Digits</h1>
<script>
function myfun()
{
var n;
n=document.getElementById("no").value;
var R,S=0;
while(n!=0)
{
R=n%10;
S=S+R;
n=Math.floor(n/10);
}
document.write("THE SUM IS OF THE DIGIT IS : " + S);
}
</script>
<form>
Enter The No. To Find Sum of Digits:<input type="number"
id="no"><br><br>
WEB PROGRAMMING
36
FYBSC.IT DIV:-B ROLL NO:-212

<input type="submit" value="Check" onclick="myfun()">


</form>
</body>
</html>
Output:-

PRACTICAL NO 3 (e)
AIM : e)Write a program in JavaScript to accept a sentence from the user and  display the
number of words in it. (Do not use split () function).

CODE :
<html>
<title>vidhan_practical3E</title>
<body>
<div align= "center">
<h1>Count of Words</h1>
<p>Type in the text box and click on the button to count th
words</p>
<textarea id="inputField" cols="58" rows="8" > </textarea>
<p>
<button onclick="countWords()"> Count words </button>
WEB PROGRAMMING
37
FYBSC.IT DIV:-B ROLL NO:-212

<p> Word Count:


<span id="show">0</span></p>
<script>
function countWords() {
var text = document
.getElementById("inputField").value;
var numWords = 0;
for (var i = 0; i < text.length; i++) {
var currentCharacter = text[i];
if (currentCharacter == " ") {
numWords += 1;
}
}

document.getElementById("show")
.innerHTML = numWords;
}
</script>

</body>
</html>

WEB PROGRAMMING
38
FYBSC.IT DIV:-B ROLL NO:-212

Output:-

PRACTICAL NO 3 (f)
AIM : f) Write a java script program to design simple calculator.

CODE :
<html>
<head>
<style>
div input[type=button]{
background-color: grey;
border: none;
color: #000000;
padding: 15px 30px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
WEB PROGRAMMING
39
FYBSC.IT DIV:-B ROLL NO:-212

}
</style>
</head>
<body>
<form id="xyz" name="abc" align="center">
<input name="result"><br>
<input name="answ"><br><br>
<div>

<input type="button" name="7" value="7"


onclick="run7()">
<input type="button" name="8" value="8"
onclick="run8()">
<input type="button" name="9" value="9"
onclick="run9()">
<input type="button" name="+" value="+"
onclick="runadd()"> <br>

<input type="button" name="4" value="4"


onclick="run4()">
<input type="button" name="5" value="5"
onclick="run5()">
<input type="button" name="6" value="6"
onclick="run6()">

WEB PROGRAMMING
40
FYBSC.IT DIV:-B ROLL NO:-212

<input type="button" name="-" value="-"


onclick="runsub()"><br>

<input type="button" name="1" value="1"


onclick="run1()">
<input type="button" name="2" value="2"
onclick="run2()">
<input type="button" name="3" value="3"
onclick="run3()">
<input type="button" name="*" value=" *"
onclick="runmul()"> <br>

<input type="button" name="/" value=" /"


onclick="rundiv()">
<input type="button" name="." value=" ."
onclick="runpoint()">
<input type="button" name="0" value="0"
onclick="run0()">
<input type="button" name="=" value="="
onclick="runresl()"><br>

<input type="button" name="c" value="c"


onclick="runreset()"> <br>

WEB PROGRAMMING
41
FYBSC.IT DIV:-B ROLL NO:-212

</div>
</form>
<script>
function run1(){
document.abc.result.value+="1";
}
function run2(){
document.abc.result.value+="2";
}
function run3(){
document.abc.result.value+="3";
}
function run4(){
document.abc.result.value+="4";
}
function run5(){
document.abc.result.value+="5";
}
function run6(){
document.abc.result.value+="6";
}
function run7(){
document.abc.result.value+="7";
WEB PROGRAMMING
42
FYBSC.IT DIV:-B ROLL NO:-212

}
function run8(){
document.abc.result.value+="8";
}
function run9(){
document.abc.result.value+="9";
}
function run0(){
document.abc.result.value+="0";
}
function runadd(){
document.abc.result.value+="+";
}
function runsub(){
document.abc.result.value+="-";
}
function runmul(){
document.abc.result.value+="*";
}
function rundiv(){
document.abc.result.value+="/";
}
function runpoint(){
document.abc.result.value+=".";
WEB PROGRAMMING
43
FYBSC.IT DIV:-B ROLL NO:-212

}
function runresl(){
var ans=eval(document.abc.result.value);
document.abc.answ.value=ans;
}
function runreset(){
document.getElementById("xyz").reset();
}
</script>
</body>
</html>
Output:-

WEB PROGRAMMING
44
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 4 (a)
AIM : a) Control and looping statements and Javascript references.

CODE :
<html>
<head>
<title>vidhan_practical4A</title>
<script type="text/javascript">
var age = prompt("Please enter your age");
if(age>=18)
document.write("You are an adult <br />");

if(age<18)
document.write("You are NOT an adult <br />");

var hours = new Date().getHours();


if(hours<12)
document.write("Good Morning ! <br />");
else
document.write("Good Afternoon !<br />");

var one = prompt("Enter the first number");


var two = prompt("Enter the second number");
one = parseInt(one);
WEB PROGRAMMING
45
FYBSC.IT DIV:-B ROLL NO:-212

two = parseInt(two);
if (one == two)
document.write(one + " is equal to " + two + ".");
else if (one<two)
document.write(one + " is less than " + two + ".");
else
document.write(one + " is greater than " + two + ".");
</script>
</head>
<body>
</body>
</html>
Output:-

WEB PROGRAMMING
46
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 4 (b)
AIM : b) Design a web page demonstrating different looping statements.

CODE:
<!DOCTYPE html>
<html>
<head>
<title>vidhan_practical4B</title>
</head>
<body>
<form>
<h1 align="center">FOR LOOP</h1>
ENTER THE NO.TO PRINT SERIES UPTO THAT NO:<input
type="number" id="no1"><br><br>
<input type="submit" value="Check" onclick="myforloop()">
<h1 align="center">WHILE LOOP</h1>
ENTER THE NO.TO PRINT SERIES UPTO THAT NO:<input
type="number" id="no2"><br><br>

WEB PROGRAMMING
47
FYBSC.IT DIV:-B ROLL NO:-212

<input type="submit" value="Check" onclick="mywhileloop()">

<h1 align="center">DO WHILE LOOP</h1>


ENTER THE NO.TO PRINT SERIES UPTO THAT NO:<input
type="number" id="no3"><br><br>
<input type="submit" value="Check" onclick="mydowhileloop()">
</form>

<script>
function myforloop() {
var n;
n=document.getElementById("no1").value;
for(i=1;i<=n;i++)
{
document.write( i+" <br>");
}
}
function mywhileloop() {
var n,i=1;
n=document.getElementById("no2").value;
while(i<n)
{
document.write(i + "<br>");
i++;
WEB PROGRAMMING
48
FYBSC.IT DIV:-B ROLL NO:-212

}
}
function mydowhileloop()
{
var n,i=1;
n=document.getElementById("no3").value;
do
{
document.write(i + "<br>");
i++;
}
while(i<n);
}
</script>
</body>
</html>
Output:-

WEB PROGRAMMING
49
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
50
FYBSC.IT DIV:-B ROLL NO:-212

Practical no:- 4(C)


Design a web page demonstrating different Core JavaScript 
references Array
Code:-
<!DOCTYPE html>
<html>
<head>
<title>vidhan_practical4C_1</title>
<script language="javascript">
var cars=["lambo","maserati", "audi"];
document.write("Array length is: "+cars.length);
document.write("<br>");
cars.push("RR");
document.write("<br>");
document.write("After insert: "+cars.toString());
document.write("<br>");
cars.pop();
document.write("After delete: "+cars.toString());
document.write("<br>");
cars.sort(); document.write("After sort: "+cars.toString());
document.write("<br>");
cars.reverse();
WEB PROGRAMMING
51
FYBSC.IT DIV:-B ROLL NO:-212

document.write("After reverse: "+cars. toString());


</script>
</head>
<body>
</body>
</html>
OUTPUT:-

(c2) Boolean
<!DOCTYPE html>
<html>
<head>
<title>vidhan_practical4C_2</title>
<script language="javascript">
function myFunction() {
document.getElementById("demo").innerHTML=Boolean (10
> 9);
}

WEB PROGRAMMING
52
FYBSC.IT DIV:-B ROLL NO:-212

</script>
</head> <body>
<p>Display the value of Boolean (10 > 9):
</p>
<button onclick="myFunction()">Try it</button>
<p id="demo" ></p>
</body>
</html>

(c3) Date
CODE:-
<!DOCTYPE html>

<html>

<head>

<title>vidhan_practical4c_3</title>

WEB PROGRAMMING
53
FYBSC.IT DIV:-B ROLL NO:-212

<script language="javascript">

var currentDate = new Date();

document.write("date is :");
document.write(currentDate.getDate()+"/"+
(currentDate.getMonth()+1)+"/"+currentDate.getFullYear()
+"<br>");
document.write("Time is :");
document.write(currentDate.getHours()
+":"+currentDate.getMinutes()
+":"+currentDate.getSeconds());

</script>
</head>
<body>
</body>
</html>
OUTPUT:-

WEB PROGRAMMING
54
FYBSC.IT DIV:-B ROLL NO:-212

(C4) Function
CODE:- <!DOCTYPE html>
<html>
<head>
<title>vidhan_prac4c_4</title>
<script language="javascript">
addBraces=new Function("s","return'['+s+']'");
document.write (addBraces ("Have"));
document.write(addBraces("a"));
document.write(addBraces ("great"));
document.write(addBraces ("life"));
</script>
</head>
<body>
</body>
</html>
OUTPUT:-
WEB PROGRAMMING
55
FYBSC.IT DIV:-B ROLL NO:-212

(C5) MathNumber
CODE:-
<html>
<head>
<title>vidhan_practical4c_5</title>
<script language="javascript">
document.write("Random number:
"+Math.random(4)+"<br>");
document.write("Minimum number: "+Math.min
(777,27,67,-77)+"<br>");
document.write("Maximum number: "+Math.max
(999,299,399,899)+"<br>");
document.write("Round (77.6): "+Math.round
(77.6)+"<br>");
document.write("Ceil(5.6): "+Math.ceil(5.6) +"<br>");
document.write("Floor (7.4): "+Math.floor(7.4)+"<br>");
document.write("Square root of 5: "+Math.SQRT5+"<br>");
document.write("Square root of 2/4:
"+Math.SQRŢ2_4+"<br>");
WEB PROGRAMMING
56
FYBSC.IT DIV:-B ROLL NO:-212

document.write("4 raise to 4: "+Math.pow(4,4)+"<br>");


</script>
</head>
<body>
</body>
</html>
OUTPUT:-

(C6) Object STRING


CODE:-
<!DOCTYPE html>
<html>
<head>
<title>vidhan_practical4c_6</title>
<script language="javascript">
myobj1=new Object(777);
document.write(myobj1.toString()+"<br>");
myobj2=new Object("hello moto");
document.write(myobj2.valueOf());

WEB PROGRAMMING
57
FYBSC.IT DIV:-B ROLL NO:-212

</script>
</head>
<body>
</body>
</html>
OUTPUT:-

(C7) regExp
CODE:-
<html>
<head>
<title>vidhan_practical4c_7</title>
<script language="javascript">
var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.write(txt.length);
document.write("<br>");

var x = 'nothing is right';


var y = "We are the \"NINJAS\" from the hidden leaf village.";
document.write(x + "<br>" + y);
WEB PROGRAMMING
58
FYBSC.IT DIV:-B ROLL NO:-212

document.write("<br>");
var str = "Please locate where 'locate' occurs!";
var pos = str.indexOf("locate");
document.write(pos);
document.write("<br>");
var str = "Please locate where 'locate' occurs!";
var pos = str.lastIndexOf("locate");
document.write(pos);
document.write("<br>");
var str = "Please locate where locate' occurs!";
var pos = str.search("locate");
document.write(pos);
document.write("<br>");
var str = "guawa, orange, papaya";
var res = str.slice (7, 13);
document.write(res);
document.write("<br>");
var str = "guawa, orange, papaya";
var res= str.substring(7, 13);
document.write(res);
document.write("<br>");
var str = "guawa, orange, papaya";
WEB PROGRAMMING
59
FYBSC.IT DIV:-B ROLL NO:-212

var res = str.substr(7, 6);


document.write(res);
document.write("<br>");
var str = "Please visit Microsoft!";
var n= str.replace("Microsoft", "W3Schools");
document.write(n);
document.write("<br>");
var text1= "Hello moto!";
var text2 = text1.toUpperCase();
document.write(text2);
document.write("<br>");
var text1= "Hello moto!";
var text2 = text1.toLowerCase();
document.write(text2);
document.write("<br>");

var text1 = "Hello";


var text2 = "moto";
text3 = text1.concat(" ", text2);
document.write(text3);
var str = "HELLO MOTO";
documet.write(str.charAt(0));
WEB PROGRAMMING
60
FYBSC.IT DIV:-B ROLL NO:-212

var str = "HELLO MOTO";


documet.write(str.charCodeAt(0));
document.write("<br>");

</script>
</head>
</body>
</html>
OUTPUT:-

WEB PROGRAMMING
61
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 5 (a)
Basic PHP I

AIM : a) Write a PHP Program to accept a number from the user and print it factorial.

Source code for HTML:

<html>
<head>
<title>Factorial of a number</title>
</head>
<body>
<form method="post" action=" 5a wp.php">
Enter a number: <input type="text" name="n1"><br>
<input type="submit" value="Factorial">
</form>
</body>
</html>
Source code for PHP:

<?php
$n1=(int)$_POST['n1'];
$fact=1;
for ($i=1;$i<=$n1;$i++)
{
$fact=$fact*$i;

WEB PROGRAMMING
62
FYBSC.IT DIV:-B ROLL NO:-212

}
echo "Factorial of ".$n1." is: ".$fact;
?>
Output:-

PRACTICAL NO 5 (b)
AIM : b) Write a PHP program to accept a number from the user and print whether it  is
prime or not.

Code:
<html>
<head>
<title>212 vidhan 5b</title>
</head>
<body>
<form method="post" action="
wp 5a.php">
Enter a number: <input type="text" name="n1"><br>
<input type="submit" value="CheckPrime">
WEB PROGRAMMING
63
FYBSC.IT DIV:-B ROLL NO:-212

</form>

</body>
</html>
Source code for PHP:
<?php
$n1=(int)$_POST['n1'];
$flag=0;
for($i=2;$i<=$n1/2;$i++)

{
if($n1%$i==0)
{
$flag=1;
break;
}
}
if($flag==0)
echo "Number is prime";
else
echo "Number is not prime";
?>

OUTPUT:-

WEB PROGRAMMING
64
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
65
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 6 (a)
AIM : a) Write a PHP code to find the greater of 2 numbers. Accept the no. from the 
user.
Source code for HTML:
<html>
<head>
<title>Greater of two numbers</title>
</head>
<body>
<form method="post" action=" wp 6a.php">
1st Number: <input type="text" name="n1"><br>
2nd Number: <input type="text" name="n2"><br>
<input type="submit" value="Check">
</form>
</body>
</html>
Source code for PHP:
Source code for PHP:
<?php
$n1=(int)$_POST['n1'];
$n2=(int)$_POST['n2'];
if($n1>$n2)
echo $n1." is greater than ".$n2;
else if($n2>$n1)

WEB PROGRAMMING
66
FYBSC.IT DIV:-B ROLL NO:-212

echo $n2." is greater than ".$n1;


else
echo "Both the no.s are equal";
?>
OUTPUT:-

PRACTICAL NO 6 (b)

AIM : b) Write a PHP program to display the following Binary


Pyramid: 

0 1 
1 0 1  
0101

Code:
<?php
for($i=0;$i<4;$i++)
{
for($j=0;$j<=$i;$j++)
{
WEB PROGRAMMING
67
FYBSC.IT DIV:-B ROLL NO:-212

if(($i+$j)%2==0)
echo "1 ";
else
echo "0 ";
}
echo "<br>";
}
?>

OUTPUT:-

WEB PROGRAMMING
68
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 7 (a)
String Functions and arrays

AIM : a) Write a PHP program to demonstrate different string


functions.

Code:
<?php
echo strlen("VIDHAN \n");
echo "<br />";
echo strchr("Hello world!","world");
echo "<br />";
echo str_replace("world","mam","Hello world!");
echo "<br />";
echo str_word_count("Hello world!");
echo "<br />";
echo strpos("I love php, I love php too!","php");
echo "<br />";
echo substr_count("Hello world. The world is nice","world");
echo "<br />";
echo substr("Hello world",6);
echo "<br />";
echo strtolower("Hello WORLD.");
echo "<br />";
echo strtoupper("Hello WORLD.");
WEB PROGRAMMING
69
FYBSC.IT DIV:-B ROLL NO:-212

?>
OUTPUT:-

PRACTICAL NO 7 (b)

AIM : b) Write a PHP program to create one dimensional array.

Code:
<?php
$cars = array("LAMBO", "MASERATI", "RR");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
echo "<br>";
echo "Total number of car: " . count($cars);
echo "<br>";
$arrlength = count($cars);
for($x = 0; $x < $arrlength; $x++)
{
echo $cars[$x];
echo "<br>";
}
//Associative arrays
$age = array("HARSHAD"=>"18", "GWEN"=>"37", "OMI"=>"43");
WEB PROGRAMMING
70
FYBSC.IT DIV:-B ROLL NO:-212

echo "VIDHAN is " . $age['HARSHAD'] . " years old.";


?>
OUTPUT:-

WEB PROGRAMMING
71
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 8 (a)
PHP and Database

AIM : a) Write a PHP code to create:


(part 1)

i) Create a database College

CODE:
<?php
//connecting to the database
$servername = "localhost";
$username = "root";
$password = "";

//create a connection
$conn = mysqli_connect($servername, $username,
$password);

//Die if connection was not sucessful

if(!$conn){

WEB PROGRAMMING
72
FYBSC.IT DIV:-B ROLL NO:-212

die("Sorry we failed to connect: ".


mysqli_connect_error());
}
else{
echo "Connection was succesfully";
echo "<br>";
}

//create a database
$sql = "CREATE DATABASE Patkar_College1";
$result = mysqli_query($conn, $sql);

//Checck for the data creation success


if($result){
echo "Data base created successfully";
}
else{
echo "Data base creation failed because of this
error --->" . mysqli_error($conn);
}

?>
WEB PROGRAMMING
73
FYBSC.IT DIV:-B ROLL NO:-212

OUTPUT:-

PRACTICAL NO 8 (a)(part2)

ii) Create a table Department  (Dname, Dno, Number_of_faculty)

CODE:
<?php
//connecting to the database
$servername = "localhost";
$username = "root";
$password = "";
$databse = "Patkar_College1";

//create a connection
WEB PROGRAMMING
74
FYBSC.IT DIV:-B ROLL NO:-212

$conn = mysqli_connect($servername, $username, $password,


$databse);

//Die if connection was not sucessful

if(!$conn){
die("Sorry we failed to connect: ". mysqli_connect_error());
}
else{
echo "Connection was succesful";
echo "<br>";
}

//create a table in database


$sql = "CREATE TABLE `department` ( `Dname` VARCHAR(20)
NOT NULL , `Dno` INT(11) NOT NULL , `Number of faculty`
INT(14) NOT NULL )";
$result = mysqli_query($conn, $sql);

//Check the table was created or not


if($result){
echo "The table creation was succes";
}
else{
echo "The table ws not created because of this error --->".
mysqli_error($conn);
WEB PROGRAMMING
75
FYBSC.IT DIV:-B ROLL NO:-212

}
?>
OUTPUT:-

PRACTICAL NO 8 (b)

AIM : b) Write a PHP program to create:


a) database named “College”. Create a table named “Student” with following fields (sno, sname,
percentage). Insert 3 records of your choice. Display the names of the students whose percentage is
between 35 to 75 in a tabular format.

CODE:
<?php

//connecting to the database

$servername = "localhost";

$username = "root";

$password = "";

$databse = "Patkar_College";

//create a connection

$conn = mysqli_connect($servername, $username, $password, $databse);


WEB PROGRAMMING
76
FYBSC.IT DIV:-B ROLL NO:-212

//Die if connection was not sucessful

if(!$conn){

die("Sorry we failed to connect: ". mysqli_connect_error());

else{

echo "Connection was succesful";

echo "<br>";

//Inserting student data in databse

$sql = "INSERT INTO `student` (`sno`, `name`, `percentage`) VALUES (NULL, 'Balmukund', '67')";

$result = mysqli_query($conn, $sql);

//Check the data in table inserted or not

if($result){

echo "The student's data inserted in table succesfully";

else{

echo "The student's data not inserted in table succesfully". mysqli_error($conn);

?>

OUTPUT:

WEB PROGRAMMING
77
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
78
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 8 (c)

AIM : c) Design a PHP page for authenticating a user.

CODE:
Source code for HTML:

<html>

<head>
<title>User authentication</title>
</head>

<body>
<form method="post" action="wp practical php file 8c.php">
Username: <input type="text" name="t1"><br>
Password: <input type="password" name="p1"><br>
<input type="submit" value="Submit">&nbsp;
<input type="reset" value="Clear">
</form>
</body>

</html>

Source code for php:

<?php
$user=$_POST['t1'];

WEB PROGRAMMING
79
FYBSC.IT DIV:-B ROLL NO:-212

$pass=$_POST['p1'];
if($user=="vidhan" && $pass=="123")
echo "Welcome ".$user;
else
echo "Invalid username and password";
?>
OUTPUT:

WEB PROGRAMMING
80
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 9
AIM : Design an XML document and display it in browser using XSL

CODE:
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rule.xsl" ?>
<student>
<s>
<name>vidhan pawar</name>
<board>HSC</board>
<age>18</age>
<city>MUMBAI</city>
</s>
<s>
<name>harshad pawar</name>
<board>HSC</board>
<age>18</age>
<city>MUMBAI</city>
</s>
<s>

WEB PROGRAMMING
81
FYBSC.IT DIV:-B ROLL NO:-212

<name>vaibhav pednekar</name>
<board>HSC</board>
<age>19</age>
<city>MUMBAI</city>
</s>
</student>
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1 align="center">STUDENT DETAILS</h1>
<table border="3" align="center">
<tr>
<th>NAME</th>
<th>BOARD</th>
<th>AGE</th>
<th>CITY</th>
</tr>
<xsl:for-each select="student/s">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="board"/></td>
<td><xsl:value-of select="age"/></td>
<td><xsl:value-of select="city"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
WEB PROGRAMMING
82
FYBSC.IT DIV:-B ROLL NO:-212

<html>
<body>
<h1 align="center">Students' Basic Details</h1>
<table border="3" align="center">
<tr>
<th>NAME</th>
<th>BOARD</th>
<th>AGE</th>
<th>CITY</th>
</tr>
<tr>
<td>vidhan pawar</td>
<td>HSC</td>
<td>18</td>
<td>MUMBAI</td>
</tr>
<tr>
<td>harshad pawar</td>
<td>HSC</td>
<td>18</td>
<td>MUMBAI</td>
</tr>
<tr>
<td>Vaibhav pednekar</td>
<td>HSC</td>
<td>18</td>
<td>MUMBAI</td>
</tr>
</table>
</body>
</html>

OUTPUT:-

WEB PROGRAMMING
83
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL NO 10
Email

AIM : Send email with attachment.

CODE:
<?php
// Recipient
$to = '[email protected]';
// Sender
$from = '[email protected]';
$fromName = 'vidhan';
// Email subject
$subject = 'PHP Email with Attachment by Ayush';
// Attachment file
$file = "prac.pdf";
// Email body content
$htmlContent = '
<h3>PHP Email with Attachment by vidhan</h3>
<p>This email is sent from the PHP script with attachment.</p>
';
// Header for sender info
$headers = "From: $fromName"." <".$from.">";
// Boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Headers for attachment
WEB PROGRAMMING
84
FYBSC.IT DIV:-B ROLL NO:-212

$headers .= "\nMIME-Version: 1.0\n" . "Content-Type:


multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// Multipart boundary
$message = "--{$mime_boundary}\n" . "Content-Type: text/html;
charset=\"UTF-8\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";
// Preparing attachment
if(!empty($file) > 0){
if(is_file($file)){
$message .= "--{$mime_boundary}\n";
$fp = @fopen($file,"rb");
$data = @fread($fp,filesize($file));
@fclose($fp);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: application/octet-stream;
name=\"".basename($file)."\"\n" .
"Content-Description: ".basename($file)."\n" .
"Content-Disposition: attachment;\n" . "
filename=\"".basename($file)."\"; size=".filesize($file).";\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
}
}
$message .= "--{$mime_boundary}--";
$returnpath = "-f" . $from;
// Send email
$mail = @mail($to, $subject, $message, $headers, $returnpath);
// Email sending status

WEB PROGRAMMING
85
FYBSC.IT DIV:-B ROLL NO:-212

echo $mail?"<h1>Email Sent Successfully!</h1>":"<h1>Email


sending failed.</h1>";
?>

OUTPUT:

WEB PROGRAMMING
86
FYBSC.IT DIV:-B ROLL NO:-212

PRACTICAL 11
AIM: Demonstrate use of sessions and cookies
<?php
session_start();
?>
<html>
<body>
<?php
$_SESSION["favcar"] = "RR";
$_SESION["favfruit"] = "DRAGON FRUIT";
echo "Session variables are set.";
?>
</body>
</html>
OUTPUT:-

Code for cookies:


<?php
$cookie_name = "user";

WEB PROGRAMMING
87
FYBSC.IT DIV:-B ROLL NO:-212

$cookie_value = "HARSHAD ";


setcookie($cookie_name, $cookie_value, time() + (86400 *
30), "/");
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$cookie_name])){
echo "Cookie named '" . $cookie_name . "' is not
set! ";
}
else{
echo "Cookie '" . $cookie_name . "' is set! <br>";
echo "Value is : " . $_COOKIE[$cookie_name];
}
?>
OUTPUT:-

WEB PROGRAMMING
88
FYBSC.IT DIV:-B ROLL NO:-212

WEB PROGRAMMING
89

You might also like