You are on page 1of 89

Name: Shivam Prajapati Web Programing

Roll No.: - 64

RAMNIRANJAN JHUNJHUNWALA COLLEGE GHATKOPAR (W), MUMBAI - 400


086

DEPARTMENT OF INFORMATION TECHNOLOGY

2021 -2022

F.Y. B. Sc.( I.T.) SEM I


RJSUIT1P5
Web programing

Name Shivam Parmesh Prajapati


Roll No.: -064

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Hindi Vidya Prachar Samiti’s

RAMNIRANJAN JHUNJHUNWALA
COLLEGE
Ghatkopar (W), Mumbai-400 086

Certificate

This to certify that Mr.Shivam P. Prajapati. Roll


no.:64. FY-B.SC (I.T) Class has completed the required
Number of experiments in the subject of
WEB PROGRAMING in the dipartment of Information
Technology of academic year 2021 – 2022.

Professor In-Charge Co-ordinator of IT


Department
Prof. Bharati Bhole
Prof.Archana
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64

Bhide

College Seal & Date Examine

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

INDEX
Practical Practical Details Dates Remarks
No.

1. Use of Basic Tags 23/01/22

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 11/02/22

a. Design a web page with Image maps. 14/02/22

b. Design a web page demonstrating different


semantics

c. Design a web page with different tables.


Design a web pages using 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. JavaScript 16/02/22

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 JavaScript.

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
c. Write a JavaScript program to display all the
prime numbers between 1 and 100.

a. Write a JavaScript program to accept a


number from the user and display the sum of
its digits.

d. Write a program in Java Script to accept a


sentence from the user and display
the number of words in it. (Do not use split()
function).

e. Write a javascript program to design a simple


calculator.

4. Control and looping statements and 05/03/22


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 22/03/22

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 25/03/22

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:
1
01
101
0101

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
7. String Functions and arrays 25/03/22

a. Write a PHP program to demonstrate different


string functions.

b. Write a PHP program to create a one dimensional


array.

8. PHP and Database 24/03/22

a. Write a PHP code to create:


● CreateadatabaseCollege
● 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 ofyourchoice.Displaythenamesofthestu
dentswhosepercentageisbetween35to75 in
a tabular format.

9. Email 26/03/22

a. Write a program to send email with attachment.

10. Sessions and Cookies 26/03/22

a. Write a program to demonstrate use of sessions


and cookies

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical-1 Use Of Basic Tags.
a) Design a web page using different formating tags.

Source code:-

<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<style>
</style>
</head>
<body>
<p> <b> SHIVAM PRAJAPATI </b> </p>
<p><strong>I love coding.</strong></p>
<p><i>HTML5 is computer language.</i></p>
<p><em>Good morning.</em></p>
<p><mark>My roll no. is 64.</mark></p>
<p><u>I am learning Web Programming.</u></p>
<p><strike>HTML5 is not supported teletype.</strike></p>
<p><sup>Ramniranjan Jhunjhunwala College.</sup></p>
<p><sub>Today is very 🥶 environment.</sub></p>
<p><del>Display detected content.</del></p>
<p><ins>Display added content.</ins></p>
<p><big>Shivam is very Intelligent 🤓.</big></p>
<p><small>HTML5 having 14 FORMATTING tags</small></p>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:-

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
b) Design a web page with links to different pages and allow navigation between web
pages.
a. Create page one.html having a link to two.html, create two.html having a link to
three.html. Print "Welcome to Hyperlinks" in three.html.
b. Create an html page and demonstrate "Hyperlinking to anchor" i.e. linking within the
same page using the concept of bookmarks/anchors.

Source code:-

One.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>One</title>
<style>
</style>
</head>
<body>
<a href="two.html">Go to Two.html</a>

</body>
</html>

Two.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Two</title>
<style>
</style>
</head>
<body>
<a href="three.html">Go to three.html</a>
<p><b>Shivam Parmesh Prajapati.</b></p>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
</body>
</html>

Three.html
<!DOCTYPE html>

<hrtml>

<head>

<title>Three</title>

</head>

<body>

Welcome to Hyperlinks.

</body> </html>

Output:-

B)
Source code:-

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

<!DOCTYPE html>

<html>

<head>
<title>linking within the same file</title>

</head> <body>

Ca name=”top”>top region</a>

<br>

<a href=”#bottom”>go to bottom</a> <!-add large texual content <a


name=”bottom”>bottom region</a>

<br>

<a href=”#top”>go to top</a>

</body> </html>

Output:-

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
C) Design a web page demonstrating all Style sheet types:

Generate a nested list as follows: (Display Fruits and Vegetables in "red" font color using
inline style, Display Mango, Banana and Apple in font color "Blue" and Tomato, Potato
and Carrot in font color "Yellow" using internal stylesheet, set background color for
Fruits and Vegetables to pink using external stylesheet). Hint: use id/class attributes
and/or styles for nested tags.

A) Fruits .

1) Mango
2) Banana
3) Apple

B) Vegetables

IV. Tomato
V. Potato
VI.Carrot

#) CREATE YOUR OWN WEB PAGE USE THE ABOVE EXAMPLE AS REFERENCE.

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Source code:-

<!DOCTYPE html>
<html>
<head>
<title>nested lists</title>
<style type=”text/css”>
Subject & Teachers Name Of 1st Semester (color:blue)
Subject & Teachers Name Of 2nd Semester (color:yellow)
</style>
<link rel=”stylesheet” type=”text/css” href=”one.css”> </head>
<body>
<ul style=”list-style-type:filled square”>
<li class=”bg” style=”color:red”> Subject & Teachers Name Of 1st Semester</li>
<ol style=”list-style-type:upper-roman”>
<li class=”Subject & Teachers Name Of 1st Semester”>Operating system – Punam Sindhu
ma’am
</li>
<li class=” Subject & Teachers Name Of 1st Semester”>Digital Electronic – Archana
ma’am</li>
<li class=” Subject & Teachers Name Of 1st Semester” > Impreative Programing – Priyasha
Ma’am</li>
<li class=” Subject & Teachers Name Of 1st Semester” > Communication Skills – Jeba
Ma’am</li>
<li class=” Subject & Teachers Name Of 1st Semester” > Discrete Mathematics- Poonam
Ma’am</li>
</ol> </ul>
<ol style=”list-style-type:lower-alpha”> <li class=”bg” style=”color:red”> Subject &
Teachers Name Of 2nd Semester</li>
<ol class=”grp1” start=”6” style=”list-style-type:uppper-roman”>
<li class=”Subject & Teachers Name Of 2nd Semester”> Web Programming - Anju Rai </li>
<li class=”Subject & Teachers Name Of 2nd Semester”> Green computing – Priyasha
Ma’am</li>
<li class=”Subject & Teachers Name Of 2nd Semester”> Microprocessor Architecture –
Archana ma’am</li>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
<li class=”Subject & Teachers Name Of 2nd Semester”> Numerical and Statistics Method-
Sahh wasif sir</li>
<li class=”Subject & Teachers Name Of 2nd Semester”> Python Programming- Jeba
ma’am</li>
</ol>

Output:-

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 2

2) Image maps, Tables, Forms and Media.

a) Design a web page with Image maps.


Source code:-
<!DOCTYPE html>
<html>
<head>
<title>ImageMap</title>
</head>
<body>
<map name="m1">
<area shape="rectangle" coords="224,234" href="Sun.html">
<area shape="cicle" coords="205,151" href="Galaxy.html">
</map>
<h3> Image Insertion Operation By Shivam Prajapati </h3>
<img src="C:\Users\Admin\Pictures\RenTech\space.jpg" usemap="#m1">
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:-

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Design a web page which shows all the semantic elements.

Source code:

<!DOCTYPE html>

<html>

<head>

<header><h2> Semantic Tag Performation</h2> </header>

<head>

<style>

aside {

width: 30%;

padding-left: 15px;

margin-left: 15px;

float: right;

font-style: italic;

background-color: lightgray;

</style>

</head>

<body>

<nav>

<h4>NAV having a link which discribe how to use NAV tag</h4>

<a href="https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_nav">NAV</a> l

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
</nav>

<section>

<h3>"Use of <big><u>SECTION</u></big> tag!!!"</h3>

<p> Now I am using section tag.

The "section" element defines a section in a document.

</p>

<article>

<header>

<h3 style="color:blue">The Use Of Article Tag. </h3>

</header>

<p> The "artical" element specifies independent, self-contained content.

An article should make sense on its own, and it should be possible to distribute it
independently from the rest of the web site.

</p>

</article>

<header> <h3>Use Of aside Tag.</h3></header>

<aside>

<p>"Hii Everyone My name is Shivam Prajapati.</p>

</aside>

<footer>
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
<p>HTML CODE WRITER: SHIVAM PRAJAPATI</p>

<p><a href="mailto:prajapatishivam7634@gmail.com" >

prajapatishivam7634@gmail.com</a></p></footer>

<header><h2>USE OF "FIGURE" TAG.</h2></header>

<figure>

<img src="/storage/emulated/0/Download/download.jpeg" alt="THANKS" style="width:50%">

<figcaption>@SHIVAM'S THANKING YOU.</figcaption>

</figure>

</body>

</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
C. Design a web page with different tables. Design a web pages using table so that the content
appears well placed.

Source code:

<!DOCTYPE html>

<html>

<style>

table, th, td {

border:1px solid black;

</style>

<body>

<h3>A basic HTML table by "Shivam Prajapati"</h3>

<header><img src="/storage/emulated/0/Download/download (1).jpeg "heigt="100"


width="355">

<h5>List of students and their marks</h5>

<table style="width:100%">

<tr>

<th>Name</th>

<th>Roll no.</th>

<th>Subject</th>

<th>Marks</th>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
<th>Grade</th>

</tr>

<tr>

<td>Shivam Prajapati</td>

<td>64</td>

<td>Microprocessor Architecture</td>

<td>100</td>

<td>O++</td>

</tr>

<tr>

<td>Zainab Khan</td>

<td>41</td>

<td>Python Programing</td>

<td>98</td>

<td>O+</td>

</tr>

<tr>

<td>Himanshu Chaurasiya</td>

<td>15</td>

<td>Web Programing</td>

<td>95</td>

<td>A++</td>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
</tr>

<tr>

<td>Satya Pandey</td>

<td>58</td>

<td>Numerical and Statiscal Method</td>

<td>90</td>

<td>A+</td>

</tr>

<tr>

<td>Shivam Pal</td>

<td>54</td>

<td>Green Computing</td>

<td>88</td>

<td>A</td>

</tr>

</table>

<footer>

<p>HTML CODE WRITER: SHIVAM PRAJAPATI</p>

<p><a href="mailto:prajapatishivam7634@gmail.com" >

prajapatishivam7634@gmail.com</a></p></footer>

</body>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
</html>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
D. Design a web page with a form that uses all types of controls.

Source code:

<!DOCTYPE html>

<html>

<body>

<h2>HTML Forms By <strong>Shivam Prajapati</strong></h2>

<form action="/action_page.php">

<label for="fname">First name:</label><br>

<input type="text" id="fname" name="fname" value="Shivam"><br>

<label for="lname">Last name:</label><br>

<input type="text" id="lname" name="lname" value="Prajapati"><br><br>

</form>

<p>Choose your acedmic year:</p>

<form>

<input type="radio" id="fyit" name="acedmic_year" value="FYIT">

<label for="fyit">FYIT</label><br>

<input type="radio" id="syit" name="acedmic_year" value="SYIT">

<label for="syit">SYIT</label><br>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
<input type="radio" id="tyit" name="acedmic_year" value="TYIT">

<label for="tyiy">TYIT</label>

</form>

<p>Which mode of <strong>Learning</strong> you prefered:</p>

<form action="/action_page.php">

<input type="checkbox" id="online_mode" name="online_mode" value="Comfertable or not">

<label for="online_mode"> I am comfertable in Online mode.</label><br>

<input type="checkbox" id="offline_mode" name="offline_mode" value="Comfertable or not">

<label for="offline_mode"> I am comfertable in Offline lectures.</label><br>

<input type="checkbox" id="both_mode" name="both_mode" value="Comfertable or not">

<label for="both_mode"> I am comfertable in both mode.</label><br><br>

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

</form>

</body>

</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
E.Design a web page embedding with multimedia features.

Source code:
<!DOCTYPE html>
<html>
<head>
<title>Multimedia</title>
</head>
<body>
<header>Multimedia Implementation By Shivam Prajapati</header>
Video File: <video width="240" height="320" controls>
<source
src="/storage/emulated/0/DCIM/Camera/video_20220213_101336.mp4"
type="video/ogg">
</video>
<br>
Audio File: <audio width="240" height="320" controls>
<source
src="/storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Media/
WhatsApp Audio/AUD-20211214-WA0022.mp3">
</audio>
<footer>
<p>HTML CODE WRITER: SHIVAM PRAJAPATI</p>
<p><a href="mailto:prajapatishivam7634@gmail.com" >
prajapatishivam7634@gmail.com</a></p></footer>

</body>
</html>
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical – 3. JAVA SCRIPT

A. Using JavaScript design, a web page that prints factorial/Fibonacci series/any given
series.
a.Factorial.
Source code:-

<!DOCTYPE html>
<html>
<head>
<title>Factorial Demo</title>
<script language=”javascript”>
Var x=parseInt(prompt(“Enter a number”,””));
Var fact=1,I;
For(i=1;i<=x;i++)
Fact*=I;
Document.write(“<h1>Factorial of “+x+” is : “+fact+”</h1>”);
</script>
</head>
<body>
</body>
</html>

Output:

b.Fibonacci:-
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
Source code:
<!DOCTYPE html>
<html>
<head>
<title>Fibonacci series Demo</title>
<script language=”javascript”>
Var a=0,b=1,c,n,I;
N=parseInt(prompt(“Enter limit for fibonacci series:”,””));
Document.write(“<h2> Fibonacci series: </h2><br>”);
Document.write(a+” “+b+” “);
For(i=2;i<n;i++)
{
C=a+b;
Document.write(c+” “);
A=b;
B=c;
}
</script>
</head>
<body>
</body>
</html>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Design a form and validate all the controls placed on the form using Java
Script.

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

Source code:
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
<script type="text/javascript">
function validate()
{
if( document.myForm.Name.value == "" )
{
alert( "Please provide your name!" );
document.myForm.Name.focus();
return false;
}
if( document.myForm.EMail.value == "" )
{
alert( "Please provide your Email!" );
document.myForm.EMail.focus();
return false;
}
if( document.myForm.MobileNo.value == "" ||isNaN(
document.myForm.MobileNo.value ) ||
document.myForm.MobileNo.value.length != 10)
{
alert( "Please provide your MobileNo in the format ##########!" );
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
document.myForm.MobileNo.focus();
return false;
}
{
alert( "Please provide a zip in the format ##########." );
document.myForm.MobileNo.focus();
return false;
}

if( document.myForm.Zip.value == "" ||isNaN(


document.myForm.Zip.value ) ||
document.myForm.Zip.value.length != 5 )
{
alert( "Please provide a zip in the format #####." );
document.myForm.Zip.focus();
return false;
}
if( document.myForm.Country.value == "-1" )
{
alert( "Please provide your country!" );
return false;
}
return(true);
}
</script>
</head>
<body>
<form name="myForm" onsubmit="return(validate());">
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td align="right">Name</td>
<td><input type="text" name="Name" /></td>
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
</tr>
<tr>
<td align="right">EMail</td>
<td><input type="text" name="EMail" /></td>
</tr>
<tr>
<td align="right">MobileNo</td>
<td><input type="text" name="MobileNo" /></td>
</tr>
<tr>
<td align="right">Zip Code</td>
<td><input type="text" name="Zip" /></td>
</tr>
<tr>
<td align="right">Country</td>
<td>
<select name="Country">
<option value="-1" selected>[choose yours]</option>
<option value="1">USA</option>
<option value="2">UK</option>
<option value="3">INDIA</option>
</select>
</td>
</tr>
<tr>
<td align="right"></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
C.Write a JavaScript program to display all the prime numbers between 1 and 100.

Source code:
<!DOCTYPE html>
<html>
<head>
<h4>Prime no. between 1 to 100.</h4>
<title>prime number</title>
<script>
for(var i=1;i<=100;i++)
{
var flag=0;
for(var j=2;j<=i/2;j++)
{
if(i%j==0)
{
flag=1;
break;
}
}
if(flag==0)
{
document.write(i+"<br>");
}
}
</script>
</head>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
d.Write a JavaScript program to accept a number from the user and display the sum of its
digits.

Source code:

<!DOCTYPE html>
<html>
<head>
<h3>Sum of digits of any given numbers </h3>
<title>sum of digits</title>
<script>
Var n=parseInt(prompt(“Enter the number”,” “));
Var p=0,y;
While(n>0)
{
Y=n%10;
N=parseInt(n/10);
P=p+y;
}
Document.write(“Sum of digits is: “+p);
</script>
</head>
</html>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

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).

Source code:

<!DOCTYPE html>
<html>
<head>
<h3>Finding how many words are given in the sentence.</h3>
<title>Without using split function</title>
<script>
var str=prompt("Enter the sentence=","");
var count=0;
for(i=0;i<str.length;i++)
{
if(str.charAt(i,1)==" " && str.charAt(i+1,1)!=" ")
count++;
}
document.write("Number of words are="+(count+1));
</script>
</head>
<body>
</body>
</html>
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
f.Write a java script program to design simple calculator.

Source code:
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<script language=”javascript”>
Function calc()
{
Var n1,n2,opr,x;
N1=parseInt(f1.s1.value);
N2=parseInt(f1.s3.value);
Opr=f1.s2.value;
If(opr==”add”)
X=n1+n2;
Else if(opr==”sub”)
X=n1-n2;
Else if(opr==”multi”)
X=n1*n2;
Else if(opr==”div”)
X=n1/n2;
Else
Alert(“please select operator”);
Document.getElementById(“ans”).innerHTML=”answer is:”+x;
}
</script>
</head>
<body>
<form name=”f1”>
<table width=50%>
<tr>
<td>Number1<br>
<select name=”s1” size=2>
<option>Select</option>
<option value=”0”>0</option>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
<option value=”1”>1</option>
<option value=”2”>2</option>
<option value=”3”>3</option>
<option value=”4”>4</option>
<option value=”5”>5</option>
<option value=”6”>6</option>
<option value=”7”>7</option>
<option value=”8”>8</option>
<option value=”9”>9</option>
</select>
</td>
<td>Operator<br>
<select name=”s2” size=2>
<option>Select</option>
<option value=”add”>+</option>
<option value=”sub”>-</option>
<option value=”multi”>*</option>
<option value=”div”>/</option>
</select>
</td>
<td>Number 2<br>
<select name=”s3” size=2>
<option>Select</option>
<option value=”0”>0</option>
<option value=”1”>1</option>
<option value=”2”>2</option>
<option value=”3”>3</option>
<option value=”4”>4</option>
<option value=”5”>5</option>
<option value=”6”>6</option>
<option value=”7”>7</option>
<option value=”8”>8</option>
<option value=”9”>9</option>
</select>
</td>
<td>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
<input type=”button” value=”calculate” onclick=”calc()”>
</td>
</tr>
</table>
</form>
<p id=”ans”> </p>
</body>
</html>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Practical 4. Control and looping statements and JavaScript references

A. Design a web page demonstrating different conditional statements.

Source Code:
<!-- Name: Shivam Prajapati
Roll No:64
Use of Conditional Statement -->
<!DOCTYPE html>
<html>

<head>
<title>Conditional Statements</title>
<script language="javascript">
var Roll_No = prompt("Enter Your Roll No.");
if (Roll_No > 64) {

document.write("<b>Student belonging to Batch 2</b>");


}
else
document.write("<b>Student belonging to Batch 1</b>");

</script>
</head>
<body>
</body>

</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Design a web page demonstrating different looping statements.
Source Code:
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript For Loop</h2>

<p id="demo"></p>

<script>
const student = ["Shivam", "Himanshu", "sanjeet", "Sandeep", "Gaurav", "Romit"];

let text = "";


for (let i = 0; i < student.length; i++) {
text += student[i] + "<br>";
}

document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
C. Design a web page demonstrating different Core JavaScript references (Array, Boolean, Date,
Function, Math, Number, Object, String, regExp).
a) Arrays and Object
Source code ;
<!DOCTYPE html>
<html>
<body>
<h2>Shivam Prajapati</h2>
<h2>JavaScript Arrays</h2>

<p id="demo"></p>

<script>
const cars = ["Bugati", "Mercedes", "Suzuki", "TATA", "Roals Royals"];
document.getElementById("demo").innerHTML = cars;
document.write("Array length is: "+cars.length+"<br>");
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
b. Boolean Object
Source Code:
<!DOCTYPE html>
<html>
<body>
<h2>Shivam Prajapati</h2>
<h2>JavaScript Booleans</h2>
<p>Display the value of Boolean(64> 41):</p>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = Boolean(10 > 9);
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
c. Date Object
Source Code:
<!DOCTYPE html>
<html>
<body>
<h2>Today's Date</h2>
Current Date and Time: <span id="txt"></span>
<script>
var today=new Date();
document.getElementById('txt').innerHTML=today;
</script>
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
D. Function.
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Functions</h2>

<p>This example calls a function which performs a calculation, and returns the result:</p>

<p id="demo"></p>

<script>
function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(41, 64);
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
E. Math.
Source Code:
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Math</h2>

<p>Math.PI returns PI:</p>


<p id="piDemo"></p>

<p>Math.sqrt(64) returns the square root of 64:</p>


<p id="sqrtDemo"></p>

<script>
document.getElementById("piDemo").innerHTML = Math.PI;
document.getElementById("sqrtDemo").innerHTML = Math.sqrt(64);
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

F. Java Script Number


Source Code:
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Numbers</h2>

<p>Numbers can be written with or without decimals:</p>

<p id="demo"></p>

<script>
let x = 64;
let y = 64.41;
document.getElementById("demo").innerHTML = x + "<br>" + y;
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
G. JavaScript String
Source code:
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Strings</h2>

<p id="demo"></p>

<script>
let text = "Shivam Prajapati"; // String written inside quotes
document.getElementById("demo").innerHTML = text;
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

H. Regular Expression.
Source Code:

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript String Methods</h2>

<p>Search a string for "Shivam", and display the position of the match:</p>

<p id="demo"></p>

<script>
let text = "Visit Shivam!";
let n = text.search("Shivam");
document.getElementById("demo").innerHTML = n;
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

I. JavaScript Object:
Source code:
<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Variables</h2>

<p id="demo"></p>

<script>
// Create and display a variable:
let Student_Roll_No = "64";
document.getElementById("demo").innerHTML = Student_Roll_No ;
</script>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 5 – Basic of PHP 1

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

Source Code:
<!-- Shivam Prajapati
Roll No.- 64 -->
<html>
<head>
<title>Factorial of a number</title>
</head>
<body>
<form method="post" action= "fact.php">
Enter a number: <input type="text" name="n1"><br>
<input type="submit" value="Factorial">
</form>
<?php
$n1=(int)$_POST['n1'];
$fact=1;
for($i=1;$i<=$n1;$i++)
{
$fact=$fact*$i;
}
echo "Factorial of ".$n1." is: ".$fact;
?>
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B. Write a PHP program to accept a number from the user and print whether it is prime or not.
Source Code:
<!-- Shivam Prajapati
Roll No.-64 -->

<!DOCTYPE html>
<html>
<head>
<title>Prime Number</title>
</head>
<body>
<form method="post" action="checkPrime.php">
Enter a number: <input type="text" name="n1"><br>
<input type="submit" value="CheckPrime">
</form>
<?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 $n1. "is prime Number";
else
echo $n1. "is not prime Number";
?>
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 6 - Basic PHP II

A.Write a PHP code to find the greater of 2 numbers. Accept the no. from the user.
Source code:
<!-- Shivam Prajapati
Roll No.- 64 -->
<!DOCTYPE html>
<html>
<head>
<title>Greater of two no.s</title>
</head>
<body>
<form method="post">
1st Number: <input type="text" name="n1"><br>
2nd Number: <input type="text" name="n2"><br>
<input type="submit" value="Check">
</form>
<?php
$n1=(int)$_POST['n1'];
$n2=(int)$_POST['n2'];
if($n1>$n2)
echo $n1." is greater than ".$n2;
else if($n2>$n1)
echo $n2." is greater than ".$n1;
else

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
echo "Both the no.s are equal";
?>
</body>
</html>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Write a PHP program to display the following Binary Pyramid:
1
0 1
1 0 1 0 1 0 1

Source code:

<!-- Shivam Prajapati


Roll No.- 64 -->
<!DOCTYPE html>
<title>Binary Pyramid</title>
<html>
<body>
<?php
for($i=0;$i<4;$i++)
{
for($j=0;$j<=$i;$j++)
{
if(($i+$j)%2==0)
echo "1 ";
else
echo "0 ";
}
echo "<br>";
}
?>
</html>
</body>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 7 -String Functions and arrays
A.Write a PHP program to demonstrate different string functions.
Source Code:
<!-- Shivam Prajapati
Roll No.- 64 -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>String Function</title>
</head>
<body>
<?php
echo strlen("SHIVAM");
echo "<br>";
echo strchr("Hello SHIVAM!","HIMANSHU");
echo "<br>";
echo str_replace("SHIVAM","ZAINAB","Hello SHIVAM!");
echo "<br>";
echo str_word_count("Hello SHIVAM!");
echo "<br>";
echo strpos("I love myself!","myself");
echo "<br>";
echo substr_count("Hello SHIVAM. Nice to meet you","to");
echo "<br>";
echo substr("Hello SHIVAM",6);

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
echo "<br>";
echo strtolower("Hello SHIVAM.");
echo "<br>";
echo strtoupper("Hello SHIVAM.");
echo "<br>";
echo strcmp("Hello SHIVAM!","My roll no is 64!");
echo "<br>";
echo strcasecmp("My roll no is 64!","Hello SHIVAM!");
echo "<br>";
?>
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Write a PHP program to create one dimensional array.
Source Code:
<!-- Shivam Prajapati
Roll No.- 64 -->
<!DOCTYPE html>
<head>
<title>Creating One dimensional Array.</title>
</head>
<html>
<body>
<?php
$cars = array("Baleno", "BMW", "Ford");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
echo count($cars);
$arrlength = count($cars);
for($x = 0; $x < $arrlength; $x++)
{
echo $cars[$x];
echo "<br>";
}
//Associative arrays
$age = array("Shivam"=>"18", "Hima"=>"19", "Pal"=>"54");
echo "Shivam is " . $age['Shivam'] . " years old."; ?>
</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 8 - PHP and Database
A.Write a PHP code to create:
● Create a database College
● Create a table Department (Dname, Dno, Number_Of_faculty)
Source Code:
<!-- Shivam Prajapati

Roll No.- 64 -->

<DOCTYPE html>

<head>

<title>Creating database</title>

</head>

<html>

<body>

<?php

$con=mysql_connect("localhost","root","");

if(!$con)

die('could not connect:'.mysql_error());

if(mysql_query("create database College",$con))

echo"Database Created successfully";

else

echo "Error creating database:".mysql_error();

mysql_select_db("College",$con);

$query="create table department(dname varchar(50),dno smallint,no_of_faculty smallint)";

if(mysql_query($query,$con))

echo"Table Created successfully";

else

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
echo "Error creating table:".mysql_error();

mysql_close($con);

?>

</body>

</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
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 ofyourchoice.Displaythenamesofthestudentswhosepercentageisbetween35to75 in a
tabular format.
Source Code:

<!-- Shivam Prajapati

Roll No.-64 -->

<DOCTYPE html>

<html>

<head>

<title>Database insert and select</title>

</head>

<body>

<?php

$con=mysql_connect("localhost","root","");

if(!$con)

die('could not connect:'.mysql_error());

if(mysql_query("create database College",$con))

echo"Database Created successfully";

else

echo "Error creating database:".mysql_error();

mysql_select_db("College",$con);

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
$query="create table student(sno smallint,sname varchar(50),percentage
decimal(7,2))";

if(mysql_query($query,$con))

echo"Table Created successfully";

else

echo "Error creating table:".mysql_error();

$query1="insert into student values(64,'SHIVAM',99)";

if(mysql_query($query1,$con))

echo"Record 1 inserted successfully";

else

echo "Error inserting record 1:".mysql_error();

$query2="insert into student values(15,'HIMANSHU',80)";

if(mysql_query($query2,$con))

echo"Record 2 inserted successfully";

else

echo "Error inserting record 2:".mysql_error();

$query3="insert into student values(54,'SHIVAM PAL',75)";

if(mysql_query($query3,$con))

echo"Record 3 inserted successfully";

else

echo "Error inserting record 3:".mysql_error();


Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
$sql="select * from student where percentage>=35 and percentage<=75";

$result=mysql_query($sql,$con);

if(mysql_num_rows($result)>0)

echo "<table
border='1'><tr><th>Sno</th><th>Sname</th><th>Percentage</th></tr>";

while($row=mysql_fetch_assoc($result))

echo "<tr>";

echo "<td>".$row['sno']."</td>";

echo "<td>".$row['sname']."</td>";

echo "<td>".$row['percentage']."</td>";

echo "</tr>";

echo "</table>";

else

echo "Table is empty";

mysql_close($con);
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
?>

</body>

</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64

Without Condition Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
With Condition Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 9 - Email
A. Write a program to send email with attachment.
Source code:
<!-- Shivam Prajapati
Roll No.-64 -->
<?php
$to = "prajapatishivam7634@gmail.com";
$sub = "Generic Mail";
$msg="Hello Geek! This is a generic email.";
if (mail($to,$sub,$msg))
echo "Your Mail is sent successfully.";
else
echo "Your Mail is not sent. Try Again.";
?>

Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Practical 10 - Sessions and Cookies

A.Write a program to demonstrate use of sessions and cookies.


Source Code:
<!-- Shivam Prajapati
Roll No.- 64. -->
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>

<?php
// Echo session variables that were set on previous page
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";
echo "Favorite animal is " . $_SESSION["favanimal"] . ".";

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
?>

</body>
</html>

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
Output:

Ramniranjan Jhunjhunwala College


Name: Shivam Prajapati Web Programing
Roll No.: - 64
B.Code for writing cookies in PHP.
Source Code:
<!-- Shivam Prajapati
Roll No.- 64 -->
<!DOCTYPE html>
<?php
$cookie_name = "user";
$cookie_value = "Shivam Prajapati";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); // 86400 = 1 day
?>
<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];
}
?>

<p><strong>Note:</strong> You might have to reload the page to see the value of the
cookie.</p>

</body>
Ramniranjan Jhunjhunwala College
Name: Shivam Prajapati Web Programing
Roll No.: - 64
</html>

Output:

Ramniranjan Jhunjhunwala College

You might also like