Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A Lab Manual
of
S VINOD KUMAR
V MALLESI
Dr. U. U VEERENDRA
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
REG No : ______________________________
SEMESTER : II
Laboratory outcomes:
Course Objectives:
Develop a static and dynamic webpage by the use of java script and DHTML
Understand, analyze and apply the role of mark up languages like HTML,
DHTML, and XML in the workings of the web and web applications.
Design static pages in more organized format by using style sheets and
techniques like AJAX for making its content dynamic and Use cascading style
sheets to design web pages.
Write a server side java application called Servlet,JSP to catch form data sent
from client, process it and store it on database.
Understanding the impact of web designing in the current market place where
everyone use to prefer electronic medium for shopping, commerce, fund
transfer and even social life also.
ABOUT LAB
Software
1 All systems are configured in DUAL BOOT mode i.e., Students can boot
from Windows 8 or Linux as per their lab requirement. This is very useful
for students because they are familiar with different Operating Systems so
that they can execute their programs in different programming
environments.
2 Microsoft-Office 2007 software tool.
1 Equipment in the lab for the use of student community. Students need to
maintain a proper decorum in the computer lab. Students must use the
equipment with care. Any damage is caused is punishable.
3 Students are supposed to occupy the machines allotted to them and are
not supposed to talk or make noise in the lab. The allocation is put up on
the lab notice board.
4 Lab can be used in free time / lunch hours by the students who need to use
the systems should take prior permission from the lab in-charge.
Students are not supposed to use floppy disks or any other external memories
(pen drives etc.).
TEXT BOOKS:
1. Beginning PHP and MySQL,3rd Edition , Jason Gilmore, Apress Publications (Dream tech.).
2. PHP 5 Recipes A problem Solution Approach Lee Babin, Nathan A Good, Frank M.Kromann
and Jon Stephens.
3. Deitel and Deitel and Nieto, ―Internet and World Wide Web - How to Program, Prentice
Hall,5th Edition,2011.
4. Herbert Schildt, ―Java-The Complete Reference, Eighth Edition, Mr Graw Hill Professional,
It should contain the following name (text box), address (multiline text
box), gender (radio button male, female), skill sets known (check boxes – C, C++,
JAVA C# etc) extracurricular activities (text box), nationality (combo box) submit
and reset button.
Aim: To design a simple web page of student bio-data form using HTML5.
Source Code:
<html>
<body>
<table cellpadding="2" width="20%" bgcolor="Choice" align="center"
cellspacing="2">
<tr>
<td colspan=2>
<center><font size=4><b>Student Registration Form</b></font></center>
</td>
</tr>
<tr>
<td>Name</td>
<td><input type=text name=textnames id="textname" size="30"></td>
</tr>
<tr>
<td>Father Name</td>
<td><input type="text" name="fathername" id="fathername" size="30"></td>
</tr>
<tr>
<tr>
<td>Gender</td>
<td><input type="radio" name="gender" value="male" size="10">Male
<tr>
<td>Email-Id</td>
<td><input type="text" name="emailid" id="emailid" size="30"></td>
</tr>
<tr>
<td>DOB</td>
<td><input type="text" name="dob" id="dob" size="30"></td>
</tr>
<tr>
<td>MobileNo</td>
<td><input type="text" name="mobileno" id="mobileno" size="30"></td>
</tr>
<tr>
<td>ADDRESS <br /><br /><br /></td>
<td><textarea name="Address" rows="4" cols="32"></textarea></td>
</tr>
<tr>
<td>State</td>
<td><select Name="State">
<option value="-1" selected>select..</option>
<option value="Andhra Pradesh">ANDHRA PRADESH</option>
<option value="Telangana">TELANGANA</option>
<option value="Karnata">KARNATAKA</option>
<option value="Tamilnadu">TAMILNADU</option>
<option value="New Delhi">NEW DELHI</option>
</select>
</td>
</tr>
<tr>
<td>SKILL SETS <br /><br /><br /></td>
<td>
C
<input type="checkbox" value="C" />
C++
<input type="checkbox" value="C++" />
JAVA
<input type="checkbox" value="JAVA" />
C#
<input type="checkbox" value="C#" />
<br />
Others
<input type="checkbox" value="Other">
<input type="text" maxlength="30" />
</td>
</tr>
<tr>
<td><input type="reset"></td>
<td colspan="2"><input type="submit" value="Submit Form" /></td>
</tr>
</table>
</body>
</html>
Aim: To design a multiple web pages with different types of frames using HTML5.
Procedure: Open NOTEPAD++ and create 1St File name (Mainpage.html), 2nd File
name (Frame.html), 3rd File name (Floatingframe.html), 4th File name
(Mixedframe.html), 5th File Name (navigationframe.html), 6th File Name
(pic.html) and 7th File name (video.html)
Source Code:
Mainpage.html
<html>
<body>
<a href="frames.html" target="two">navigation frame</a><br>
<a href="floatingframe.html" target="two">floating frame</a><br>
<a href="Noframe.html" target="two">no frame</a><br>
<a href="mixedframe.html" target="two">mixed frame</a><br>
</body>
</html>
Frame.html
<html>
<frameset cols="20%,35%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html"></frame>
<frame src="aa.gif"></frame>
<frame name="two" src="cc.gif"></frame>
</frameset>
</html>
Floatingframe.html
<html>
<body>
<p> Explanation: There is a problem with the page you are trying to reach and it
cannot be displayed.
Try the following: * Refresh page: Search for the page again by clicking the
<html>
<frameset cols="30%,*">
<frame src="pic.html"></frame>
<frameset rows="50%,*">
<frame src="video.html" autostart="true">
<frame src="Q3.html" >
</frameset>
</frameset>
</html>
navigationframe.html
<html>
<frameset cols="25%,*" scrolling="no" noresize>
<frame name="one" src="MainPage.html">
</frame>
<frame name="two" ></frame>
<frameset rows="30%,*">
<frame src="hulk.gif">
</frame>
</frameset>
</html>
<html>
<body>
<img src="ghanendra.jpg" height="650" width="400">
</body>
</html>
video.html
<html>
<body bgcolor="aqua">
<embed src="aa.mp4" width="600" height="300" autostart="true">
</embed>
</body>
</html>
Output:-
Aim: To design web pages by applying the different styles using inline, external &
internal style sheets using HTML5.
b) Include the internal style sheet for body tags & also use class name, so that the
style can be applied for all tags.
1. Selector (Element)
2. Style (Attribute)
3. Property and
4. Value
Selector is normally HTML element that element you want to assign CSS style.
And style is attribute to assign CSS property and set suitable value.
OUTPUT:
AIM: To design a java script program to read .XML file and display data in a neat
format.
Procedure:
Source Code:
library.xml
<?xml version="1.0"?>
<!-- Last edited by http://encodedna.com -->
<Library>
<List>
<code>1</code>
<BookName>Computer Architecture</BookName>
<Category>Computers</Category>
<Price>125.60</Price>
</List>
<List>
<code>2</code>
<BookName>Advanced Composite Materials</BookName>
<Category>Science</Category>
<Price>172.56</Price>
</List>
<List>
<code>3</code>
<BookName>Asp.Net 4 Blue Book</BookName>
<Category>Programming</Category>
<Price>56.00</Price>
</List>
<List>
<code>4</code>
<BookName>Stategies Unplugged</BookName>
<Category>Science</Category>
<Price>99.99</Price>
</List>
<List>
<code>5</code>
<html>
<head>
<title>Extract XML Data using JavaScript</title>
<style>
#books {
margin-left: 190px;
font:13px Arial;
width:582px;
}
.col3 {
float:left;
}
</style>
<script src="readxml.js"></script>
</head>
<body>
<div id="books"></div>
</body>
</html>
readxml.js
function reportStatus() {
if (oXHR.readyState == 4) // REQUEST COMPLETED.
oXHR.onreadystatechange = reportStatus;
oXHR.open("GET", "library.xml", true);
// true = ASYNCHRONOUS REQUEST (DESIRABLE), false = SYNCHRONOUS
REQUEST.
oXHR.send();
function showTheList(xml) {
Output:
Aim: To create an JavaScript program to define a user defined function for sorting
the values in an array. Use HTML5 for user interface.
<html>
<head>
<script type="text/javascript">
var num=0;
number=0;
var numarray=new Array();
function array_size()
{
num=prompt("Enter how many number to be sorted","000");
number=parseInt(num);
get_numbers();
}
function get_numbers()
{
if (number!=null && number!="")
{
for( i=0;i<number;i++)
Source Code:
<html>
<head>
<script type="text/javascript" language="javascript">
function InputException(msg)
{
this.val = msg;
this.toString = function()
{
return "Input Exception is = "+this.val;
}
}
function AreLetters(msg)
{
var input = msg;
var re = new RegExp("[^a-zA-Z]");
if(input.match(re))
{
oops = new InputException(input);
OUTPUT:
Source Code:
File Name: index.html
<form action="servlet1">
Name:<input type="text" name="userName"/><br/>
<input type="submit" value="go"/>
</form>
FirstServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FirstServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response){
try{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n=request.getParameter("userName");
out.print("Welcome "+n);
The code for an HTML form with a file upload box is given below. User can click on
the ‘Browse’ button to select the file from his/her local machine.
<form method="POST"name="email_form_with_php"
action="php-form-action.php"enctype="multipart/form-data">
In this article we will discuss how we can design a sign-in webpage for our website
with PHP and MySQL and how to retrieve a record from the database.
Introduction
It’s easy to use PHP with MySQL to create it. But for these kind of webpages we
need to use form validation on our webpages, if anyone use JavaScript so it’s well
and good because JavaScript is a very good technique to use and solve Form
Validation problems. But we will directly go to our work just create a simple Sign-
in page to make you understand the concept of Sign-in webpage in this article.
First of all we need to design the Sign-In webpage. Commonly what we see on a
Sign-In webpage. There is username and password form boxes and a button to
sign in to the profile page of user. And also sometimes we saw CAPTCHA which is
used to identify the user on the webpage during the wrong entries of the Sign-In
webpage. There is also an easy method to put CAPTCHA on a webpage. But now
in this article we will just learn how to design a Sign-In webpage. Let’s start…
Source Code:
//login.html
<html>
<head>
<title>login page</title>
</head>
<center>
<br><br>
<br><br><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Username:<br /><input type="text" name="username" size="20" /><br />
Password:<br /><input type="password" name="pswd" SIZE="20" /><br />
<input type="submit" value="Login" />
</form>
</center>
</body>
</html>
//index.php
<?php
session_start();
if (! isset($_SESSION['name'])) {
if (isset($_POST['username'])){
$username = $_POST['username'];
$pswd = $_POST['pswd'];
Note: The Execution completes with the above tag and next pages are just for
the information purpose only, it’s not meant for the execution purpose.
Listing 1: Sign-In.html
<!DOCTYPE HTML>
<html>
<head>
<title>Sign-In</title>
<link rel="stylesheet" type="text/css" href="style-sign.css">
</head>
<body id="body-color">
<div id="Sign-In">
<fieldset style="width:30%"><legend>LOG-IN HERE</legend>
<form method="POST" action="connectivity.php">
User <br><input type="text" name="user" size="40"><br>
Password <br><input type="password" name="pass" size="40"><br>
<input id="button" type="submit" name="submit" value="Log-In">
</form>
</fieldset>
</div>
</body>
</html>
In Figure 1 you can see the output of the Listing 1. But there is a problem, as we
used the fieldset tag and the fieldset tag size is being a problem on this page. So
we should change the width of the fieldset tag size. I have a simple way to use the
Inline Style of CSS to get rid from this problem. Let’s see the inline CSS style code.
Listing 2: Inline CSS Style
Figure 2: Output of the Sign-in Webpage with updated size of fieldset tag
As you can see in the Listing 1 and 2 we used such a good Html tags to design a
simple log-in form. We used legend tag with fieldset tag to use texts on the upper
side of the form. And in the form we used method POST. And action to send data
to another webpage. Which will be PHP Programmed webpage, I named it
connectivity.php. And there is one new thing as type that is password. The
We are using POST method because it is secure. If we use GET method our data
will not private. POST is commonly being used for these kind of webpages, due to
its security. And when we are dealing with our ID and Password, so we should be
alert from the hackers. Because the GET is being used in Phishing webpages, by
which people are making fool the internet users to get their personal ID and
Password.
Now it’s time to use CSS style on the webpage to create some attraction. We can
use many kind of styles. But the good thing is that which matches to this page. For
this we will use many CSS Styles, so I think the better way is use an external file
and link it to the sing-in.html webpage. Let’s start…
Listing 3: style.css
Description of style.css
We used three ids in the external CSS style webpage. One we used for the body,
we identified it by the body-color name, and we applied CSS styles on it. In the
next one, we used for the div tag and we identified it by Sign-In in the CSS styles
webpage. In the last we used an ID for button and we applied CSS styles on it.
There are some new CSS styles as font-weight, font-size which all about to font
(text).
Figure 3: Sign-in webpage after applying CSS Style (linking the style.css webpage)
As you can see the change on the sign-in.html webpage after linking the style.css
webpage. And we used some good colors on tags to create it more attractive.
From these kind of webpages we know the importance of CSS Styles. As you can
see the Figure 1, how it was looking and how it is looking now? We should use
different type of CSS styles on our webpages. To create them attractive and more
beautiful.
(
UserNameID int(9) NOT NULL auto_increment,
userName VARCHAR(40) NOT NULL,
pass VARCHAR(40) NOT NULL,
PRIMARY KEY(UserNameID)
);
NOTE: As we didn’t create the Sign-Up page so we should insert data to the
UserName table and then we enter that data from the sign-in.html page to
connect with user profile page.
INSERT INTO
UserName (userName, pass)
VALUES
("mrbool","mrbool123");
So we completed the requirements of the database. Now we are going create a
PHP programing file. In which we will get the data and check it if the ID and
Password are available in the database and entered correct then the user will be
able to online to the user profile page.
Listing 6: connectivity.php
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'practice');
define('DB_USER','root');
define('DB_PASSWORD','');
}
else
{
echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD...
PLEASE RETRY...";
}
}
}
if(isset($_POST['submit']))
{
SignIn();
}
?>
As you can see at this stage the webpage of sign-in.html is working well. Because
we need a webpage which takes input from user’s ID and Password, and the main
thing it should not show the user’s Password which he is giving input at the
getting log-in time. When we entered the correct user’s ID and Password then
press Log-in button to get log in.
Procedure:
<html>
<head>
<title>Registration Page</title>
<script type="text/javascript">
function validate()
{
var c1=new RegExp("^[\\w]{6}$");
var c2=new RegExp("^[\\w]{6}$");
var c3=new RegExp("^[\\w]+@[\\w]+.com$");
var c4=new RegExp("^[\\d]{10}$");
var name=document.form1.uname.value;
var pwd=document.form1.password.value;
var email=document.form1.email.value;
var phone=document.form1.phnum.value;
var error="";
var f=false;
if(!name.match(c1))
{
error += "Username should be minimum of six characters\n";
f=true;
}
if(!pwd.match(c2))
{
error += "Password should be minimum of six characters\n";
f=true;
}
if(!email.match(c3))
{
error += "Email should be of format uname@domain.com\n";
f=true;
}
if(!phone.match(c4))
if(f == true)
{
window.alert(error);
f=false;
}
else
{
document.write("<CENTER><B><U>USER PROFILE</U></B></CENTER>"+
"</br><b>User Name:</b>"+document.form1.uname.value+
"</br><b>E-mail:</b>"+document.form1.email.value+
"</br><b>Phone:</b>"+document.form1.phnum.value+
"</br><b>Gender:</b>"+document.form1.gender.value+
"</br><b>DOB:</b>"+document.form1.day.value+"-"+
document.form1.month.value +"-"+ document.form1.year.value+
"</br></br></br><a href=login.html>HOME</a>"
);
}
}
</script>
</head>
<body bgcolor="#0FF5F2">
<form name="form1" method="post" action="registration.php">
<font color="red" face="arial black" size="5">
<center><u>REGISTRATION FORM</u></center>
</font>
<table align="center" cellspacing=10 cellpadding=5>
<tr>
<td>USERNAME:</td>
<td><input type="text" name="uname"></td>
<td></td>
<td></td>
</tr>
Source Code:
Config.php
<?php
$con=mysql_connect('localhost','root',''); //Database Connections
$db=mysql_select_db('student',$con); // Database Name
?>
Index.php
<?php
include('config.php'); // Database Config
/* Add Student Detail Php */
if(isset($_POST['add'])) // Check form submit or not
{
$name=$_POST['name'];
$gender=$_POST['gender'];
$department=$_POST['dept'];
$terms=$_POST['terms'];
// Check all fields are empty or not if empty return error message
if($name=='' && $gender=='' && $department=='')
if(isset($_POST['uid'])) // Get id
{
$name=$_POST['name'];
$department=$_POST['dept'];
$terms=$_POST['terms'];
if($name=='' && $gender=='' && $department=='') // Check all fields are empty
or not if empty return error message
{
$msg="All fields are mandatary.Please fill It"; // Assign Messge variable
}
else
{
$query="UPdate `student_detail` SET
name='$name',gender='$gender',department='$department',terms='$terms'";
$result=mysql_query($query);
if($result)
{
$msg="Student Detail Updated"; // Success Message
echo '<meta http-equiv="refresh" content="0;manage-
studentdetail.php?msg='.$msg.'" />';
}
}
}
?>
<?php
$eid=$_GET['id'];
$getdata=mysql_query("SELECT * FROM `student_detail` WHERE id='$eid'");
$row=mysql_fetch_array($getdata);
?>