Professional Documents
Culture Documents
It Lab Assignment Makut
It Lab Assignment Makut
HTML
1. Start your web page with an <html> tag
i) Add a heading.
ii) Add a title.
iii) Start the <body> section.
iv) Add the following text using <H1> and </H1> tags:
This Web page was designed by (your name)
v) Add the following text using <H2> and </H2> tags: My HTML assignment
vi) Add a horizontal line
vii) Insert an image to your web page.
Note: You should then refer to your image with just the filename, and NOT the entire
pathname to the file.
viii) Add another horizontal line.
ix) Enter a paragraph of text.
Write about things you have learned in html.
Make sure the text in this paragraph is a color other than black, but something one can
see.
Add a link that takes you to your favorite webpage.
x) Start a new paragraph. Add a three item ordered list. Make it creative (don’t just say
item 1, item 2, etc… and keep it clean)!
xi) Close out your body and html tags.
Source code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Question 1 IT Lab</title>
</head>
<body>
<h1>This Webpage was designed by Rupesh raj</h1>
<h2>My HTML assignment</h2>
<hr>
<img src="./dog.jpg" height="150" width="150">
<hr>
<p>
<font color="blue">
I Rupesh raj writing my first assignment in HTML. HTML stands for Hyper Text
Markup Language and is used for displaying content in a webpage. I learnt creating static webpages
which can display content on the site. Now I know how to organize my content in a webpage. I have
learnt about various tags that help us show different content in a different way. HTML 5 is the latest
version of HTML available right now. This paragraph is being written using the <p> tag. The
<p> tag indicates the start of a new paragraph.
</font>
</p>
<a href="http://www.google.com">Click this link to go to my favorite site Google!!!</a>
<p>
This is how an ordered list looks like in HTML.<br>
This is a list of fruits that I like:-
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
2
<ol>
<li>banana</li>
<li>Gauva</li>
<li>pineapple</li>
</ol>
</p>
</body>
</html>
Output: -
Source: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Question 2 IT Lab</title>
</head>
<body>
<h1>Question 2 IT Lab</h1>
<h2>This assignment is done by Rupesh raj</h2>
<hr>
<p align="justify">
<font face="calibri">
<b>Bold latter started....</b> i am Rupesh raj and This is my 2nd assignment
<b><font></b> tag and it's attributes because that is what ultimately my assignment demands
me to do and any further modification to it is kind of an overkill for this assignment. Hehehe.....
Hope this draws your attention and makes this boring page look a bit cooler.<u> As you can see that
the text in this paragraph is aligned justified so that it looks good to the eyes. This is achieved using
the align attribute of the <b><p></b> tag</u>. But there is a disadvantage to the
<b><p></b> tag and that is that it does not preserve the spaces, tabs and the new line
characters. You need to use the escape sequences for these characters.<br>
</font>
<i>Now for this we have another tag present which is called the <b><pre></b> tag or
preserve tag. This displays the content exactly the way you type it into it. Now whatever content you
see below is in preserve tag.</i>
</p>
<pre>
<font face="tahoma">
So now you don't have to use the <b><br></b> tag to insert a line break.
By the way if you are wondering how I managed to write <b>"<"</b> and <b>">"</b>
symbol then the secret to that is using the escape sequence or which we call <b>entities</b> in
HTML.
Entities allow us to write special characters in the webpage which we can't type in directly. It
also allows us to type in symbols which are not even present in the keyboard.
For example symbols like ♥, ♠, ♣, ♦. And the way you do it is by
typing <b>"&"</b> followed by the entitiy name. For example for displaying <b>"<"</b>, we
use the escape sequence or entity <b>&lt;</b>
Even this <b>"&"</b> that you are seeing in this page is written using the escape
sequence <b>&amp;</b>
Oh yeah and do not forget the semicolon (;) at the end of escape sequence else it won't
work.
</font>
</pre>
</body>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Question 3 IT Lab</title>
</head>
<body>
<h2>Question 5 IT Lab</h2>
<hr>
<br>
<br>
<br>
<br><br>
<p id="bookmark">
<h2>Section 1</h2>
Line 1.................<br>
Line 2................<br>
Line 3..................<br>
</p>
</body>
</html>
Output: -
<!doctype html>
<html>
<head>
<h2>This assignment is done by Rupesh raj</h2>
<meta charset="utf-8">
<title>Question 4 IT Lab</title>
</head>
<body>
<h2>Question 4 IT Lab</h2>
<ul>
This is an unordered list: -
<li>First item.</li>
<li>second item.</li>
<li>Third item.</li>
</ul>
<ul type="circle">
This is another unordered list with circle bullet style: -
li>First item.</li>
<li>second item.</li>
<li>Third item.</li></ul>
<ul type="square">
This is another unordered list with square bullet style: -
li>First item.</li>
<li>second item.</li>
<li>Third item.</li></ul>
<ol><font face="calibri">
This is an ordered list: -
<li>Vegetables</li>
<li>Meat</li>
<li>Fruits
<ol type="a">
<li>Apples</li>
<li>Oranges</li>
<li>Bananas</li>
</ol>
</li>
<li>Drinks
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
8
<ol type="i">
<li>Tea</li>
<li>Coffee</li>
<li>Mocktails</li>
</ol>
</li>
</font></ol>
<dl>
This is a definition list: -
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
</body>
</html>
<body>
<h2>Question 5 IT Lab</h2>
<table cellspacing="10" cellpadding="10" border="5">
<thead>
<th>D.No</th>
<th>Department Name</th>
<th>Stength</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Electrical</td>
<td>260</td>
</tr>
<tr>
<td>2</td>
<td>Electronics</td>
<td>200</td>
</tr>
<tr>
<td>3</td>
<td>machinical</td>
<td>160</td>
</tr>
</tbody>
</table>
<br>
<table cellspacing="10" cellpadding="10" border="2" align="center" title="Educational
Qualification">
<h2 align="center">Educational Qualification</h2>
<thead align="center">
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
10
<th>Qualification</th>
<th>Field</th>
<th>Board</th>
<th>Percentage/CGPA</th>
</thead>
<tbody align="center">
<tr>
<td>B.Tech</td>
<td>Electrical</td>
<td>MAKAUT</td>
<td>58%</td>
</tr>
<tr>
<td>Diploma</td>
<td>Electronics</td>
<td>WBSCTE</td>
<td>60%</td>
</tr>
<tr>
<td>10th</td>
<td>Science,Maths,Arts,Literature,Computer Science</td>
<td>ICSE</td>
<td>90.5%</td>
</tr>
</tbody>
</table>
</body>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Question 7 IT Lab</title>
</head>
<body>
<form>
<h2>Form</h2>
<table cellpadding="10" cellspacing="10">
<tr>
<td>Firstname:</td>
<td><input type="text" name="fname"></td>
</tr>
<tr>
<td>Lastname:</td>
<td><input type="text" name="lname"></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="email" name="email"></td>
</tr>
<tr>
<td>Address:</td>
<td><textarea cols="30" rows="5" name="addr"></textarea></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender">Male<br>
<input type="radio" name="gender">Female
</td>
</tr>
<tr>
<td>Course</td>
<td>
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
13
<select name="course">
<option value="CS">Computer Science</option>
<option value="EC">Electronics and
Communication</option>
<option value="IT">Information Technology</option>
<option value="EE">Electrical</option>
<option selected>-Select-</option>
</select>
</td>
</tr>
</table>
<input type="checkbox" name="agree"> I agree to the terms and conditions.<br><br>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Reset">
</form>
</body>
</html>
Output: -
CSS
Create a web page as you wish and the html elements of the page will be styled by CSS.
Source Code: -
Q10.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Question 10 IT Lab</title>
<link rel="stylesheet" type="text/css" href="stylesheet2.css">
</head>
<body>
<div id="header">
<h1>Header Section.... </h1>
</div>
<div id="wrapper">
<div id="navbar">
<ul id="menu">
<li><a href="#">Link 1....</a></li>
<li><a href="#">Link 2....</a></li>
<li><a href="#">Link 3....</a></li>
<li><a href="#">Link 4....</a></li>
<li><a href="#">Link 5....</a></li>
</ul>
</div>
<div id="content">
<div id="body">
This is the content of the page.........<br>
Whatever content we have be it file or text is placed over here....<br>
This is how this stylesheet looks like.....<br>
Rest of the content......
</div>
</div>
</div>
<div id="footer">
<h1>Footer Section of the page.....</h1>
</div>
</body>
</html>
stylesheet1.css
@charset "utf-8";
/* CSS Document */
#header{
background-color:cornflowerblue;
padding:5px;
border-radius: 10px;
color: white;
}
#navbar{
background-color: forestgreen;
padding: 0px;
border-radius: 10px;
float: left;
width: 10%;
height: 400px;
margin-top: 10px;
}
#wrapper{
}
#menu{
list-style-type: none;
padding: 0px;
}
#menu > li > a{
display: block;
padding: 10px;
background-color: darkgreen;
text-decoration: none;
color: white;
font-family: calibri;
margin: 0px;
text-align: center;
}
#menu > li > a:hover{
background-color: lawngreen;
color: black;
}
#content{
background-color: lightseagreen;
padding: 0px;
border-radius: 10px;
float: left;
width: 89%;
height: 400px;
margin-top: 10px;
margin-left: 10px;
font-family: tahoma;
}
#body{
margin: 20px;
}
#footer{
background-color: tomato;
padding:5px;
border-radius: 10px;
color: white;
margin-top: 31.5%;
text-align: center;
}
Output: -
stylesheet2.css
@charset "utf-8";
/* CSS Document */
#header{
background-color: black;
padding:10px;
border-radius: 10px;
color: springgreen;
font-family:Consolas, Andale Mono, Lucida Console, Lucida Sans Typewriter, Monaco,
Courier New, monospace;
}
#navbar{
background-color: dodgerblue;
margin-top: 10px;
width: 100%;
position: absolute;
left: 0;
}
#wrapper{
}
#menu{
list-style-type: none;
padding: 0px;
margin: 0px;
margin-left: 10%;
font-weight: 800;
font-size: 20px;
}
#menu > li{
float: left;
}
#menu > li > a{
display: block;
padding: 10px;
text-decoration: none;
color: white;
font-family: calibri;
margin: 0px;
text-align: center;
}
#menu > li > a:hover{
background-color:royalblue;
color: black;
}
#content{
background-color: yellowgreen;
padding: 0px;
border-radius: 10px;
float: left;
width: 100%;
height: 345px;
margin-top: 4.5%;
font-family: Consolas, Andale Mono, Lucida Console, Lucida Sans Typewriter, Monaco,
Courier New, monospace;
font-style: italic;
color: maroon;
font-size: 20px;
}
#body{
margin: 20px;
}
#footer{
background-color: tomato;
padding:5px;
border-radius: 10px;
color: white;
margin-top: 31%;
text-align: center;
font-family: Consolas, Andale Mono, Lucida Console, Lucida Sans Typewriter, Monaco,
Courier New, monospace;
}
Output: -
Java Script
1. Validate the fields of a form using JavaScript.
Source Code : -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Form Validation</title>
</head>
<script>
function nameValidate(name)
{
var regex=/^([A-Z]([a-z])*\s*)*$/;
if(!name.match(regex))
document.getElementById("name").innerHTML="Name cannot have special
character or number.";
else
document.getElementById("name").innerHTML="OK";
}
function passValidate(pass)
{
var regex=/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])/;
if(!pass.match(regex))
document.getElementById("pass").innerHTML="Password does not match
the pattern.";
else
document.getElementById("pass").innerHTML="OK";
}
</script>
<body>
<form>
<h2>Admission Form</h2>
<table cellpadding="10" cellspacing="10">
<tr>
<td>Name:</td>
<td><input type="text" name="fname"
onKeyUp="nameValidate(this.value)"></td><td><span id="name"></span></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="email" name="email"></td>
</tr>
<tr>
<td>Address:</td>
<td><textarea id="addr" cols="30" rows="5"
name="addr"></textarea></td>
</tr>
<tr>
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
21
<td>Password:</td>
<td><input type="password" name="pass"
onKeyUp="passValidate(this.value)"></td><td><span id="pass"></span></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input type="radio" name="gender">Male<br>
<input type="radio" name="gender">Female
</td>
</tr>
<tr>
<td>Course</td>
<td>
<select name="course" id="course" required>
<option value="" selected>-Select-</option>
<option value="CS">Computer Science</option>
<option value="EC">Electronics and
Communication</option>
<option value="IT">Information Technology</option>
<option value="EE">Electrical</option>
</select>
</td>
</tr>
</table>
<input type="checkbox" name="agree"> I agree to the terms and conditions.<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
<script>
function required()
{
var x=document.getElementsByTagName("input");
for(var i=0;i<x.length;i++)
x[i].required=true;
document.getElementById("addr").required=true;
}
required();
</script>
</html>
Output: -
<body>
<table cellpadding="10">
<h1>Welcome to Number Guessing Game</h1>
<tr>
<td><b>Enter your guess:</b></td>
<td><input type="number" id="guess"></td>
<td><input type="button" value="Guess" onClick="checkGuess()"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Restart"
onClick="start()"></td>
</tr>
</table>
</body>
<script>
var number;
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function start()
{
document.getElementById("guess").value="";
number=getRandomInt(0,1000);
alert(number);
number=919;
}
function checkGuess()
{
var guess=document.getElementById("guess").value;
if(guess==number)
alert("Congratulations You have guessed it right");
else if(guess<number)
alert("Guess a higher number");
else
alert("Guess a lower number");
}
start();
</script>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Image Rollover</title>
</head>
<body>
<img id="pic" height="200" width="200" onMouseOver="roll()">
</body>
<script>
var a=["dog.jpg","computer.jpg"];
var index=0;
function roll()
{
document.getElementById("pic").src=a[index=(index+1)%a.length];
}
</script>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<canvas id="clock" height="400" width="400">
</canvas>
</body>
<script>
var c=document.getElementById("clock");
ctx=c.getContext("2d");
ctx.translate(200,200);
function drawClock()
{
ctx.arc(0,0,180,0*Math.PI,2*Math.PI);
ctx.stroke();
ctx.moveTo(160,0);
ctx.arc(0,0,160,0*Math.PI,2*Math.PI);
ctx.stroke();
var r=140,i=3;
ctx.font="20px calibri";
ctx.textAlign="center";
ctx.textBaseline="middle";
for(var theta=0;theta<360;theta+=30)
{
var x=r*Math.cos(radians(theta));
var y=r*Math.sin(radians(theta));
if(i%12==0)
ctx.fillText(i+++"",x,y);
else
ctx.fillText((i++%12)+"",x,y);
}
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineWidth=3;
ctx.lineTo(r*Math.cos(radians(30)),r*Math.sin(radians(30)));
ctx.stroke();
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineWidth=6;
ctx.lineTo((r-10)*Math.cos(radians(60)),(r-10)*Math.sin(radians(60)));
ctx.stroke();
ctx.beginPath();
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
28
ctx.moveTo(0,0);
ctx.lineWidth=6;
ctx.lineTo((r-50)*Math.cos(radians(270)),(r-50)*Math.sin(radians(270)));
ctx.stroke();
}
function radians(deg)
{
return deg*Math.PI/180;
}
drawClock();
</script>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
</body>
<script>
var num=prompt("Enter value of n:");
var sum=0;
for(var i=1;i<=num;i++)
sum+=fibo(i);
alert("Sum of "+num+" fibonacci numbers = "+sum);
function fibo(n)
{
if(n==1)
return 0;
else if(n==2)
return 1;
return fibo(n-1)+fibo(n-2);
}
</script>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Calculator</title>
</head>
<body>
<table cellpadding="5">
<tr>
<td colspan="4"><input id="val" type="number"></td>
</tr>
<tr>
<td><input type="button" value="+" class="op" onClick="setop(this.value)"></td>
<td><input type="button" value="-" class="op" onClick="setop(this.value)"></td>
<td><input type="button" value="X" class="op" onClick="setop(this.value)"></td>
<td><input type="button" value="/" class="op" onClick="setop(this.value)"></td>
</tr>
<tr>
<td><input type="button" value="7" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="8" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="9" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="%" class="op" onClick="setop(this.value)"></td>
</tr>
<tr>
<td><input type="button" value="4" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="5" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="6" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="." class="digits" onClick="setval(this.value)"></td>
</tr>
<tr>
<td><input type="button" value="1" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="2" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="3" class="digits"
onClick="setval(this.value)"></td>
<td><input type="button" value="=" class="digits" onClick="calculate()"></td>
</tr>
<tr>
var x=document.getElementById("val");
x.value=x.value+val;
}
function equals()
{
document.getElementById("val").value=total;
}
</script>
</html>
Output: -
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<table cellspacing="10">
<tr>
<td>Email:</td>
<td><input type="text" onkeyup="validateEmail(this.value)"></td>
<td id="email"></td>
</tr>
<tr>
<td>Phone No:</td>
<td><input type="text" onKeyUp="validatePhone(this.value)"></td>
<td id="phno"></td>
</tr>
</table>
</body>
<script>
function validateEmail(val)
{
var email=/^[a-zA-Z0-9]+([_.]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+\.[a-zA-Z0-9]{2,3}$/;
if(val.match(email))
document.getElementById("email").innerHTML="OK";
else
document.getElementById("email").innerHTML="Invalid Email pattern";
}
function validatePhone(val)
{
var phone=/^[0-9]{10}$/;
if(val.match(phone))
document.getElementById("phno").innerHTML="OK";
else
document.getElementById("phno").innerHTML="Must be 10 digits";
}
</script>
</html>
Output: -
XML
3. Create an XML document that contains the name and price per pound of coffee
beans.
i) In your XML document mention all properties of XML declaration.
ii) The root element has name <coffee_bean>
iii) Create nested elements for different types of coffee.
iv) Validate the document and if any parsing error is present, fix them.
Source Code: -
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Just a Form</title>
</head>
<body>
<form action="http://localhost/cgi-bin/test.cgi">
<table cellpadding="10">
<tr>
<td>Firstname : </td>
<td><input type="text" name="fname"></td>
</tr>
<tr>
<td>Lastname : </td>
<td><input type="text" name="lname"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
Output: -
Source Code: -
<?xml version="1.0" encoding="utf-8"?>
<AIRLINES>
<CARRIER NAME="Air India">
<FLIGHT>
<FLIGHT_NO>AI-20</FLIGHT_NO>
<DEPARTURE_CITY>KOLKATA</DEPARTURE_CITY>
<DESTINATION_CITY>DELHI</DESTINATION_CITY>
<DEPARTURE_TIME>10:30AM</DEPARTURE_TIME>
</FLIGHT>
<FLIGHT>
<FLIGHT_NO>AI-50</FLIGHT_NO>
<DEPARTURE_CITY>DELHI</DEPARTURE_CITY>
<DESTINATION_CITY>KOLKATA</DESTINATION_CITY>
<DEPARTURE_TIME>3:30PM</DEPARTURE_TIME>
</FLIGHT>
</CARRIER>
<CARRIER NAME="Indigo">
<FLIGHT>
<FLIGHT_NO>6E-343</FLIGHT_NO>
<DEPARTURE_CITY>PUNE</DEPARTURE_CITY>
<DESTINATION_CITY>DELHI</DESTINATION_CITY>
<DEPARTURE_TIME>9:30AM</DEPARTURE_TIME>
</FLIGHT>
<FLIGHT>
<FLIGHT_NO>6E-501</FLIGHT_NO>
<DEPARTURE_CITY>DELHI</DEPARTURE_CITY>
<DESTINATION_CITY>KOLKATA</DESTINATION_CITY>
<DEPARTURE_TIME>3:30PM</DEPARTURE_TIME>
</FLIGHT>
</CARRIER>
<CARRIER NAME="Vistara">
<FLIGHT>
<FLIGHT_NO>UK-727</FLIGHT_NO>
<DEPARTURE_CITY>KOLKATA</DEPARTURE_CITY>
<DESTINATION_CITY>BANGALORE</DESTINATION_CITY>
<DEPARTURE_TIME>1:30PM</DEPARTURE_TIME>
</FLIGHT>
<FLIGHT>
<FLIGHT_NO>UK-534</FLIGHT_NO>
<DEPARTURE_CITY>HYDERABAD</DEPARTURE_CITY>
<DESTINATION_CITY>CHENNAI</DESTINATION_CITY>
<DEPARTURE_TIME>5:00PM</DEPARTURE_TIME>
</FLIGHT>
</CARRIER>
</AIRLINES>
Output: -
PERL
20. Write a perl script to implement the regular expression as follows:
a). If a string contains any vowel, count the total number of vowels.
Source Code: -
print "Enter String:";
$string = <STDIN>;
chomp $string;
$string =~ s/[^aeiou]//g;
print "Number of vowels = ".length($string);
Output: -
b). If a string starts with MCA and end with bw, print 1 else 0.
Source Code: -
print "Enter String:";
$string = <STDIN>;
chomp $string;
if($string =~ /^MCA([a-zA-Z])*bw$/)
{
print 1;
}
else
{
print 0;
}
Output: -
c). If string starts with 0 or any no. a’s, then print 1 else 0.
Source Code: -
print "Enter String:";
$string = <STDIN>;
chomp $string;
if($string =~ /^(0|a)+\w*$/)
{
print 1;
}
else
{
print 0;
}
Ouptut: -
CGI Script
1) Deployment of CGI – script using Apache server on Windows : -
Source Code: -
form.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Just a Form</title>
</head>
<body>
<form action="http://localhost/cgi-bin/test.cgi">
<table cellpadding="10">
<tr>
<td>Firstname : </td>
<td><input type="text" name="fname"></td>
</tr>
<tr>
<td>Lastname : </td>
<td><input type="text" name="lname"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
test.cgi
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf("<body>\n");
printf("<h1>Query string from get method= ");
printf("%s</h1>\n", getenv("QUERY_STRING"));
printf("</body>\n");
printf("</html>\n");
return 0;
}
Name :Rupesh raj Roll : 262
Branch : CSE – Sec – C Year : 4th
43
Output: -