Vous êtes sur la page 1sur 51

STUDY FORUM

Chapter 1

Introduction
Study Forum is a technology based query management system where it guides us in
various technologies like JAVA,C,C++,DOT NET ,etc. In the Study Forum we can get the best
solutions to the queries. In Forum the students who are already registered can login and then
post the queries. The students who know the answers to the queries they can post the answers.
For a single query we can get many answers also. Here we will get the most important questions
which are asked frequently in many interviews.
In this forum we may get the answers from experts in that area. This Forum is a user
friendly forum so that users can post the queries easily and as well as they can get answers.
From this Forum students can learn technologies easily .So by joining in the Forum we can
share the knowledge from others.
To Develop the Study Forum I used MYSQL, HTML, AJAX, JavaScript, Cascading
Style Sheets and PHP scripting language during the development phase. Front-end is the Webbased Interface for all users. MYSQL and PHP are friendly development tools used for the
back-end database and project development.
In the introduction, I have presented necessity of Study Forum, and the basic operations.
The Literature survey includes the brief introduction about the web 2.0 technologies and how to
adopt those technologies. The Literature survey gives correct syntax for beginners to start
learning the technology. The chapter-3 illustrates the requirements of the system. These
requirements are classified into Functional requirements and non-Functional requirements.
Chapter-4 describes the design of Study Forum System, it contains use-case diagram,
presentation diagram, process diagrams and database structure. The chapter-5 include the
implementation part, here I explained all the php scripts in abstract and PHP MySQL
connection. The chapter-6 tells about complete testing part, which includes both unit testing and
integration testing. Finally, I have printed snapshots, which are important pages in this System.

Department of Computer Science and Engineering ,UVCE.


Page-1

STUDY FORUM
Chapter 2

Literature Survey
Introduction to WEB 2.0
The term Web 2.0 is associated with web applications that facilitate participatory
information sharing, interoperability, user-centered design, and collaboration on the World
Wide Web. A Web 2.0 site allows users to interact and collaborate with each other in a social
media dialogue as creators (producers) of user-generated content in a virtual community, in
contrast to websites where users (consumers) are limited to the passive viewing
of content that was created for them. Examples of Web 2.0 include social networking
sites, blogs, wikis, video sharing sites, hosted services & web applications.
Web 2.0 websites allow users to do more than just retrieve information. By increasing
what was already possible in "Web 1.0", they provide the user with more user-interface,
software and storage facilities, all through their browser. This has been called "Network as
platform" computing. Users can provide the data that is on a Web 2.0 site and exercise some
control over that data. These sites may have an "Architecture of participation" that
encourages users to add value to the application as they use it.

The client-side/web browser technologies used in Web 2.0 development are:

Asynchronous JavaScript and XML (Ajax),

Adobe Flash and the Adobe Flex framework,

JavaScript/Ajax frameworks such as Yahoo! UI Library, Dojo Toolkit, MooTools,


and jQuery.

On the server side, Web 2.0 uses many of the new languages such as

PHP

Ruby

ColdFusion

Perl

Python

JSP and ASP

Department of Computer Science and Engineering ,UVCE.


Page-2

STUDY FORUM
are used to dynamically output the data using information from files and databases.

PHP
PHP stands for "PHP: HyperText Preprocessor". PHP is a server side scripting
language for making logic driven websites. It is used to enhance web pages. With PHP, you
can do things like create username and password login pages, check details from a form,
create forums, picture galleries, surveys, and a whole lot more. PHP doesn't get executed on
your computer, but on the computer you requested the page from. The results are then handed
over to you, and displayed in your browser. Other scripting languages you may have heard of
are JSP, ASP, Python and Perl.
There are two softwares available for developing application in php
1. Wampp (Windows apache mysql php and perl)
2. Xampp (Xml apache mysql php and perl)
PHP's syntax and semantics are similar to most other programming languages (C, Java, Perl)
with the addition that all PHP code is contained with a tag, of sorts. All PHP code must be
contained within the following...
PHP Code:
<?php
//PHP code here
?>
or the shorthand PHP tag that requires shorthand support to be enabled on your server...
<?
//PHP code here
?>
If you have PHP inserted into your HTML and want the web browser to interpret it correctly,
then you must save the file with a .php extension, instead of the standard .html extension.
PHP : Variables

Department of Computer Science and Engineering ,UVCE.


Page-3

STUDY FORUM
Variables are used for storing a values, like text strings, numbers or arrays. When a variable
is declared, it can be used over and over again in your script. All variables in PHP start with a
$ sign symbol. The correct way of declaring a variable in PHP :
$var_name = value;
New PHP programmers often forget the $ sign at the beginning of the variable. In that case it
will not work.

A function is just a segment of code, separate from the rest of your code.
function function_name( ) {
}
So you start by typing the word function. You then need to come up with a name for your
function.
Function display_error_message(){
Department of Computer Science and Engineering ,UVCE.
Page-4

STUDY FORUM
print "Error Detetceted";
}

String Functions
The string functions allow you to manipulate strings.
Concatenating Strings in PHP
In PHP, dot (.) operator is used to concatenate two or more strings together to form a single
string.

<?php
$str1 = "I Love PHP.";
$str2 = "PHP is fun to learn.";
echo $str1." ".$str2;
?>

Escaping quotes with in quotes


<?php
$str = "\"This is a PHP string examples in double quotes\"";
echo $str;
?>
Useful PHP String Functions
strlen(): This function returns the number of characters in a string.
str_replace(): This function replaces all occurrences of the search string in the main string
with the replace string.
<?php
$str = "Hello! How are you today?";
echo str_replace("Hello", "Hi", $str);
?>
trim(): This function removes whitespace from the beginning and from the end of the string.
strtoupper(): This function converts all lower case letters to upper.
ucfirst(): This function changes the first letter in the string to upper case.

Department of Computer Science and Engineering ,UVCE.


Page-5

STUDY FORUM
Working with Files in PHP
Manipulating files is a basic necessity for serious programmers and PHP gives you a
great deal of tools for creating, uploading, and editing files.
A better method to open files is with fopen( ). This function gives you more options that, such
as setting whether the file is for read only, for writing to as well, and a few more
options.
<?php
$fh = fopen("myfile.txt", "r");
if($fh==false)
die("unable to create file");
?>
The one we'll start with is readfile( ). As it's name suggest, it reads the contents of a file.
<?PHP
$file_contents=readfile("dictionary.txt");
print $file_contents;
?>
open file for reading and writing
<?php
$fh = fopen(" myfile.txt", "r+");
if($fh==false)
die("unable to create file");
?>

Department of Computer Science and Engineering ,UVCE.


Page-6

STUDY FORUM
PHP Sessions
Sessions are used to store information which can be used through-out the application
for the entire time the user is logged in or running the application. Each time a user visits
your website, you can create a session for that user to store information pertaining to that
user.
Unlike other applications, in web applications, all the stored variables and objects are
not globally available throughout all pages (unless sent through POST or GET methods to the
next page), so to tackle this problem sessions are utilized.
Before you can store any information in session variables, you must first start up the session
using the session_start() function. See below.
<?php
session_start();
?>
Storing information in a session
To store information in a session variable, you must use the predefined session variable
$_SESSION. Now, as an example, lets store user's name and their favorite color in a session.
<?php
session_start();
$_SESSION["username"] = "johny";
$_SESSION["color"] = "blue";
?>
Retrieving stored session information
<?php
session_start();
echo $_SESSION["username"];
Department of Computer Science and Engineering ,UVCE.
Page-7

STUDY FORUM
echo "<br/>";
echo $_SESSION["color"];
?>

Cookie
Cookie is a small flat file which sits on users computer, is often used to store data
which can be used to identify a user, for example, person's username. A cookie can be created
using the setcookie() function in PHP.
setcookie($name, $value, $expire, $path, $domain, $secure)

$name - name of the cookie. Example: "username"

$value - value of the cookie. Example: "john"

$expire - time (in UNIX timestamp) when the cookie will expire. Example: time()
+"3600". Cookie is set to expire after one hour.

$path - path on the server where cookie will be available.


<?php
setcookie("username", "john", time()+(60*60*24*365));
?>

Cookie information can retrieved using the predefined $_COOKIE array.


<?php echo $_COOKIE["username"]; ?>
Date() function
The PHP date() function is used to format a time and/or date.
The PHP date() function formats a timestamp to a more readable date and time.
A timestamp is a sequence of characters, denoting the date and/or time at which a certain
event occurred.
Syntax
Department of Computer Science and Engineering ,UVCE.
Page-8

STUDY FORUM
date(format,timestamp)
format - The first parameter, format, in the date function specifies how to display the
date/time. It uses different letters to represent the date and time. Some of the letters used
above are described here.

d - The day of the month, i.e. 01-31

m - Month representation in numbers, i.e. 01-12

Y - Year in four digits

Displaying dates in different formats.


<?php
echo date("Y-m-d");
echo date("Y/m/d");
echo date("M d, Y");
echo date("F d, Y");
echo date("D M d, Y");
echo date("l F d, Y");
echo date("l F d, Y, h:i:s");
echo date("l F d, Y, h:i A");
?>
Output
2011-05-02
2011/05/02
May 02, 2011
May 02, 2011
date and time Mon May 02, 2011
Monday May 02, 2011
Monday May 02, 2011, 01:20:42
Monday May 02, 2011, 01:20 AM
timestamp Optional, Specifies a timestamp. Default is the current

Department of Computer Science and Engineering ,UVCE.


Page-9

STUDY FORUM

MYSQL
MySQL is currently the most popular open source database server. It

is very

commonly used in conjunction with PHP scripts to create powerful and dynamic server-side
applications. MySQL is a relational database. A database is a structure that comes in two
flavors:
Flat database : Flat database that are just stored on hard drives like a text file.
Relational database: A relational database is much more oriented to the human mind and is
often preferred over the gabble-de-gook In a relational structured database there are tables
that store data. The columns define which kinds of information will be stored in the table.
mysql connect : When the PHP script and MySQL are on the same machine, you can use
localhost as the address you wish to connect to. localhost is a shortcut to just have the
machine connect to itself. If your MySQL service is running at a separate location you will
need to insert the IP address or URL in place of localhost.
Syntax:
mysql_connect(servername,username,password);
servername: Optional. Specifies the server to connect to. Default value is "localhost:3306"
username : Optional. Specifies the username to log in with. Default value is the name of the
user that owns the server process
password: Optional. Specifies the password to log in with. Default is ""
<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
Department of Computer Science and Engineering ,UVCE.
Page-10

STUDY FORUM
echo "Connected to MySQL<br />";
?>
The "or die(mysql..." code displays an error message in your browser if --you've probably
guessed it -- there is an error in processing the connection.
mysql_close() :The connection will be closed automatically when the script ends. To close
the connection before, use the mysql_close() function.
Select database : After establishing a MySQL connection with the code above, you then
need to choose which database you will be using with this connection. This is done with
the mysql_select_db ().
<?php
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("test") or die(mysql_error());
echo "Connected to Database";
?>
Creating the database:
The CREATE DATABASE statement is used to create a database in MySQL.
CREATE DATABASE database_name
Syntax for creating table:
CREATE TABLE table_name
(column_name1 data_type, column_name2 data_type,........)
1

Before you can enter data (rows) into a table, you must first define what kinds of data
will be stored (columns). We are now going to design a MySQL query to summon our
table from database land.

mysql_query("CREATE TABLE example(id INT NOT NULL AUTO_INCREMENT,


PRIMARY KEY(id),
name VARCHAR(30), age INT)") or die(mysql_error());
Department of Computer Science and Engineering ,UVCE.
Page-11

STUDY FORUM

INT - This stands for integer or whole number. 'id' has been defined to be an integer.

NOT NULL - These are actually two keywords, but they combine together to say that
this column cannot be null. An entry is NOT NULL only if it has some value, while
something with no value is NULL.

AUTO_INCREMENT - Each time a new entry is added the value will be incremented
by 1.

PRIMARYKEY(ID)-PRIMARY KEY is used as a unique identifier for the rows. Here we


have made "id" the PRIMARY KEY for this table. This means that no two ids can be
the same.

NAME VARCHAR(30) - Here we make a new column with the name "name"!

VARCHAR stands for "variable character". "Character" means that you can put in any
kind of typed information in this column (letters, numbers, symbols, etc). It's
"variable" because it can adjust its size to store as little as 0 characters and up to a
specified maximum number of characters.

ORDIE(MYSQL_ERROR()): This will print out an error if there is a problem in the

table creation process.


Insert Data Into a Database Table

When data is put into a MySQL table it is referred to as inserting data.

When inserting data it is important to remember the exact names and types of the
table's columns.
Syntax:
INSERT INTO table_name VALUES (value1, value2, value3,...)
The second form is
INSERT INTO table_name (column1, column2, column3,...)VALUES (value1,
value2, value3,...)
retrieving data with php & mysql

Department of Computer Science and Engineering ,UVCE.


Page-12

STUDY FORUM
5

Usually most of the work done with MySQL involves pulling down data from a
MySQL database. In MySQL, data is retrieved with the "SELECT" keyword.

'$result=mysql_query("select*fromexample")'
When you perform a SELECT query on the database it will return a MySQL Resource that
holds everything from your MySQL table, "example". We want to use this Resource in our
PHP code, so we need to store it in a variable, $result.
mysql_fetch_array (): mysql_fetch_array() is actually a PHP function that allows you to
access data stored in the result returned from a successful mysql_query. If you have been
jumping around our MySQL.
fetch rows using while loop:
<?php // Make a MySQL Connection
$query = "SELECT * FROM example";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['name']. " - ". $row['age']; }
?>
MYSQL WHERE
WHERE lets you specify requirements that entries must meet in order to be
returned in the MySQL result. Those entries that do not pass the test will be left out.
$result = mysql_query("SELECT * FROM example WHERE name='Sandy
Smith'") or die(mysql_error());
MYSQLWILDCARDUSAGE'%'
In MySQL there is a "wildcard" character '%' that can be used to search for partial
matches in your database. The '%' tells MySQL to ignore the text that would normally appear
in place of the wildcard. For example '2%' would match the following: 20, 25, 2000000x:
$result = mysql_query("SELECT * FROM example WHERE age LIKE '2%' ")
or die(mysql_error());
Department of Computer Science and Engineering ,UVCE.
Page-13

STUDY FORUM
MYSQLORDERBY
ORDER BY takes the column name that you specify and sort it in alphabetical order (or
numeric order if you are using numbers). Then when you use mysql_fetch_array to print out
the result, the values are already sorted and easy to read.

MYSQLJOINS
The act of joining in MySQL refers to smashing two or more tables into asingle table. This
means everything you have learned so far can be applied after you've created this
new, joined table.
mysql update
UPDATE - Performs an update MySQL query
SET - The new values to be placed into the table follow SET
WHERE - Limits which rows are affected
$result = mysql_query("UPDATE example SET age='22' WHERE age='21'") or
die(mysql_error());
mysql delete: used to delete the selected data and even whole data
mysql_query("DELETE FROM example WHERE age='15'")
AGGREGATE FUNCTIONS
group by:
Group BY is good for retrieving information about a group of data. If you only had one
product of each type, then GROUP BY would not be all that useful.

The column that you GROUP BY must also be in your SELECT statement.

Remember to group by the column you want information about and not the one you
are applying the aggregate function on.

Department of Computer Science and Engineering ,UVCE.


Page-14

STUDY FORUM
count - counting records
The COUNT function is an aggregate function that simply counts all the items that are in a
group.
$query = "SELECT type, COUNT(name) FROM products GROUP BY type";
sum - It is an aggregate function that totals a specific column for a group.
$query = "SELECT type, SUM(price) FROM products GROUP BY type";

JAVA SCRIPT
JavaScript is a scripting language which is developed by Netscape. It is an interpreted,
object-based scripting language. By definition, JavaScript is a client-side scripting language.
This means the web surfer's browser will be running the script. The opposite of client-side is
server-side, which occurs in a language like PHP. Following are the Use of JavaScript
Input validation - checking the type of data as users fill out each field in a form.
Object manipulation - JavaScript has many built-in functions and pre-defined objects.
And JavaScript allows the user to manipulate the document of an HTML page.
Handling events Events are user initiated actions. JavaScript supports different types
of events.
Communicating with Java and Plug-ins with Netscape Navigator 3.0 or later versions,
JavaScript can be used to communicate using Java and Plug-ins called LiveConnect.
Accessing Databases With server-side JavaScript and Netscapes tool called LiveWire,
the user can access Open Data Base Connectivity- complaint data from a database.
DATA TYPES
Data type refers to the manner in which data is stored in the memory.
Data types available in JavaScript are
Number
Boolean
String
Null
Department of Computer Science and Engineering ,UVCE.
Page-15

STUDY FORUM
VARIABLE
Variables are like storage units, they can store all kinds of data. You can create variables to
hold values. JavaScript is case-sensitive.
OPERATORS
JavaScript has many different operators such as assignment, comparison, arithmetic and
logical ,bitwise, string and some special operators.

FUNCTIONS
Functions are one of the fundamental building blocks in JavaScript. A function is a JavaScript
procedure -- a set of statements that performs a specific task.
A function definition has these basic parts:

The function keyword

A function name

A comma-separated list of arguments to the function in parentheses

The statements in the function in curly braces: { }

Defining a Function
function popupalert()
{
alert('This is an alert box.');
}
Calling a Function
<A HREF="#top" onClick="anotherAlert('top')">top</A>

Department of Computer Science and Engineering ,UVCE.


Page-16

STUDY FORUM
WORKING WITH JAVASCRIPT OBJECTS
One of the important features of JavaScript is that it is an object-based language. It supports
the development of object types and its instances. This unit describes JavaScripts
support of objects and object-based programming.
An object is defined as a single entity, which consists of two things:
data members known as Properties
member functions known as Methods, which act upon the data members.
ACCESSING OBJECTS
Each Object has some Properties and some Methods attached to it. So, accessing an object
refers to accessing Properties of an Object and accessing Methods of an Object. The
Properties of an Object can be accessed in the following manner
Object.Property
Object.Method()
The main categories of JavaScript Objects are

Browser objects

Internal objects

BROWSER OBJECTS
Browser objects are called top-level objects and are created when a browser loads a web
page. The browser objects include the window object, document object, location object,
history object. But the most commonly used pre-defined objects are the window and
document objects. These objects enable users to access various HTML related elements such
as forms, links etc. and are also used to provide dynamic effects to a web page.
INTERNAL OBJECTS
The following are the different types of internal objects:

date

Department of Computer Science and Engineering ,UVCE.


Page-17

STUDY FORUM

math

array
EVENT HANDLING IN JAVASCRIPT

Events describe actions that occur as the result of user interaction with any application.
The processing that is performed in response to the occurrence of an event is known as
Event handling.
The code that is executed when an event occurs is known as an Event handler.
It is important to know that every event is associated with a separate event handler, which
can be either user defined or system defined. The association of an event with its event
handler is through the event handling attributes of the HTML tags.

The following table summarizes the events defined by JavaScript along with the event
handling attributes.

Event name

Event handling attribute

Used in

Abort
Blur
Change
Click

onAbort
onBLur
onChange
onClick

Error
Focus
Load
Mouseover
Mouseout
Reset
Select
Submit
Unload

onError
onFocus
onLoad
onMouseOver
onMouseOut
onReset
onSelect
onSubmit
onUnload

Image
select, text, text area
select, text, text area
button, checkbox, radio,
link, reset, submit, area
image
select, text, text area
window, image
link, area
link, area
form
text, text area
form
window

Department of Computer Science and Engineering ,UVCE.


Page-18

STUDY FORUM
Regular Expressions
Regular expressions are patterns used to match character combinations in strings. In
JavaScript, regular expressions are also objects.
These patterns are used with the exec and test methods of regular expressions, and with the
match, replace, search, and split methods of String.
Creating a Regular Expression
You construct a regular expression in one of two ways:

Using an object initializer, as in: re = /ab+c/

Calling the constructor function of the RegExp object, as in: re = new RegExp("ab+c")

Writing a Regular Expression Pattern


A regular expression pattern is composed of simple characters or a combination of simple and
special characters, such as /ab*c/.
The fallowing table provides a complete list and description of the special characters that can
be used in regular expressions.
Charact Meaning
er

For characters that are usually treated literally, indicates that the next
character is special and not to be interpreted literally.
For example, /b/ matches the character 'b'. By placing a backslash in front
of b, that is by using /\b/, the character becomes special to mean match
a word boundary. -or-

Matches beginning of input or line.


For example, /^A/ does not match the 'A' in "an A," but does match it in
"An A."

Matches end of input or line.


For example, /t$/ does not match the 't' in "eater", but does match it in
"eat"

Department of Computer Science and Engineering ,UVCE.


Page-19

STUDY FORUM
*

Matches the preceding character 0 or more times.

Matches the preceding character 1 or more times. Equivalent to {1,}.


For example, /a+/ matches the 'a' in "candy" and all the a's in
"caaaaaaandy."

Matches the preceding character 0 or 1 time.

(The decimal point) matches any single character except the newline
character.

(x)

Matches 'x' and remembers the match.


For example, /(foo)/ matches and remembers 'foo' in "foo bar." The
matched substring can be recalled from the resulting array's elements [1],
..., [n], or from the predefined RegExp object's properties $1, ..., $9.

x|y

Matches either 'x' or 'y'.

{n}

Where n is a positive integer. Matches exactly n occurrences of the


preceding character.
For example, /a{2}/ doesn't match the 'a' in "candy," but it matches all of
the a's in "caandy," and the first two a's in "caaandy."

{n,}

Where n is a positive integer. Matches at least n occurrences of the


preceding character.

{n,m}

Where n and m are positive integers. Matches at least n and at most m


occurrences of the preceding character.

[xyz]

A character set. Matches any one of the enclosed characters. You can
specify a range of characters by using a hyphen.

[^xyz]

A negated or complemented character set. That is, it matches anything


that is not enclosed in the brackets. You can specify a range of characters
by using a hyphen.

[\b]

Matches a backspace. (Not to be confused with \b.)

\b

Matches a word boundary, such as a space. (Not to be confused with [\b].)

AJAX

Department of Computer Science and Engineering ,UVCE.


Page-20

STUDY FORUM
Asynchronous JavaScript + XML, while not a technology in itself, is a term coined in
2005 by Jesse James Garrett, that describes a "new" approach to using a number of existing
technologies together, including: HTMLor XHTML, Cascading Style Sheets, JavaScript, The
Document Object Model, XML, XSLT, and the XMLHttpRequest object.

Asynchronous JavaScript And XML

Technology behind interactive web sites


MySpace, Personalised Google Page, GMail etc

Provide smoother experience than conventional web pages

No need to refresh the entire page

Snippets of information are updated as necessary

By using asynchronous process user can send a request without waiting fot previous
response. The following figure shows how AJAX works

Department of Computer Science and Engineering ,UVCE.


Page-21

STUDY FORUM
The XMLHttpRequest Object
All modern browsers support the XMLHttpRequest object (IE5 and IE6 uses an
ActiveXObject).
The XMLHttpRequest object is used to exchange data with a server behind the scenes. This
means that it is possible to update parts of a web page, without reloading the whole page.
Syntax for creating an XMLHttpRequest object:
variable=new XMLHttpRequest();
Send a Request To a Server
To send a request to a server, we use the open() and send() methods of the XMLHttpRequest
object:
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();

Server Response

To get the response from a server, use the responseText or responseXML property of the
XMLHttpRequest object.
Property

Description

responseText

get the response data as a string

responseXML

get the response data as XML data

The responseText Property

If the response from the server is not XML, use the responseText property.
Department of Computer Science and Engineering ,UVCE.
Page-22

STUDY FORUM
The responseText property returns the response as a string, and you can use it accordingly:
Example

document.getElementById("myDiv").innerHTML=xmlhttp.responseText;

The onreadystatechange event


When a request to a server is sent, we want to perform some actions based on the response.
The onreadystatechange event is triggered every time the readyState changes.
The readyState property holds the status of the XMLHttpRequest.

Three important properties of the XMLHttpRequest object:


Property

Description

onreadystatech Stores a function (or the name of a function) to be called


ange

automatically each time the readyState property changes

readyState

Holds the status of the XMLHttpRequest. Changes from 0 to 4:


0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready

Status

200: "OK"
404: Page not found

In the onreadystatechange event, we specify what will happen when the server response is
ready to be processed.
When readyState is 4 and status is 200, the response is ready:
Department of Computer Science and Engineering ,UVCE.
Page-23

STUDY FORUM

Example
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}

HTML:(Hyper text markup language)


HTML is used to build an organization's retail commerce website or develop a
business-to-business solution to exchange data with trading partners. The web-based user
interface say a lot about the company, to customers or partners.
HTML is a valuable and a common component of electronic commerce.
HTML-Hyper Text Mark-up Language is a tag based language, used to mark u
specific parts of a Web page for display.
HTML is a used for describing how pages of text ,graphics and other information are
organized, formatted and linked together. The "hyper text" means text stored in electronic
form with cross-reference links between pages. The term stands for its capability to link a text
or graphic hotspot to other web pages. This powerful feature called as the hyper link is one of
the main reasons why HTML was adopted as the language for the web.
HTML can be defined as a tag-based language used to "markup specific parts of a
Web page for display. By adding tags to the page, instructions are given to the 'web browser
to display the page.

Department of Computer Science and Engineering ,UVCE.


Page-24

STUDY FORUM
The Browsers Read the web pages sequentially, interpret them and display the various
piece of content based on the HTML tags. This is known as Parsing. During parsing of a web
page, the browser maps the HTML tags in the page
HTML is maintained by a standards body called the World Web Consortium(WWC).

HTML TAGS
*<HTMLl> : <HTML></HTML>,are the first and the last tags in any page.
Everything else on the page are in between these two tags. This tag tell the browser, that the
file is webpage.

*<HEAD>: The <HEAD></HEAD>tags must the always be the first tags and should
not contain any of the page's actual content.

*<BODY>: The body tag content of the page, text, graphics, links and other HTML
elements are placed in the body tag.three common attributes of body tag are-BGCOLOR, TEXT and LINK
-BGCOLOR specifies the background color of the page.
-TEXT specifies the color of the text in the page.
-LINK specifies the color of the hyper links on the page.

*<TITLE>tags:The page title used by the browser for their bookmarks and favourites
list should be includeed in the header tags,using the title tags-<TITLE></TITLE>.

*<FONT>tags:When authorring HTML,it is common to adjust the size,face or colour


of a font for a phrase,word or a single character this tagis used.

Department of Computer Science and Engineering ,UVCE.


Page-25

STUDY FORUM
*<CENTER>tag:The center tags are commonly used,but they are not part of the
HTML standard.

*<DL>tag:The definition list tags are used to creat a definition list.

*<HR>tag:If an horizontal rule is tag is added to a page,then the browser simply


draws a line across the page.

HTMLFORMS
An HTML form is a section of a document containing normal content, markup,
special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those
controls. Users generally "complete" a form by modifying its controls (entering text, selecting
menu items, etc.), before submitting the form to an agent for processing (e.g., to a Web
server, to a mail server, etc.)
Here's a simple form that includes labels, radio buttons, and push buttons (reset the form or
submit it):
<FORM action="http://somesite.com/prog/adduser" method="post">
<P>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" id="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" id="lastname"><BR>
<LABEL for="email">email: </LABEL>
<INPUT type="text" id="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</P>
Department of Computer Science and Engineering ,UVCE.
Page-26

STUDY FORUM
</FORM>

Department of Computer Science and Engineering ,UVCE.


Page-27

STUDY FORUM
Chapter 3

Requirements specifications
Requirements are the Constraints or Services that is expected from the system. There
are two types of requirements.

User Requirements.
System Requirements.

3.1 User requirements:

Students should be able to do registration by providing required information and


also they have to manage their profile

Interfaces are user friendly forms so user must able to choose appropriate option
for prompted messages.

3.2 System requirements:


3.2.1 Functional requirements:

Student registration: System must support for student registration and to edit their
profile interface must be user friendly. System must provide proper forms for
entering new stdent record with all fields .

Posting query: system must allow users to send queries of different type of
programming languages .

View queries: system should able to display all queries along with user name and
date of posting.

Interview Questions: System should able to provide some ferequently asked


interview questions.

Answering queries: system should allow users to answer the query, on clicking
the query.

Change password: system should able provide an option to change their password
frequently.

Department of Computer Science and Engineering ,UVCE.


Page-28

STUDY FORUM
3.2.2 Non functional requirements:

Security : System should provide both user level and Network level security.

Portability : System should be platform independent, supports in all standard


browser.

Scalability : It must support even if multiple alums connected concurrently.

Availability : System must be available to use in any time(24X7).

Performance : System performance must be excellent both in time complexity


and space complexity.

Easy to work : System must provide dynamic User Interface forms

TIME SCHEDULE

Department of Computer Science and Engineering ,UVCE.


Page-29

STUDY FORUM

3.3 Hardware and Software Requirements:


Hardware requirements

Processor

Pentium III onwards

RAM

128MB

Hard disk space

40GB

Software requirements
Client system
Operating System

Windows 2000, Windows-XP, Windows-7


Linux- Fedora, Mandriva, Ubuntu, etc

Browser

Mozilla firefox, Google chrome and Internet Explorer

Server system
Operating System

Windows 2000, Windows-XP, Windows-7, Linux- Fedora,


Mandriva, Ubuntu, etc

Web Server

Apache (XAMPP or WAMPP)

Database server

MySQL server

Department of Computer Science and Engineering ,UVCE.


Page-30

STUDY FORUM
Chapter 4

Design
4.1 Usecase diagram
The use-case corresponds to a sequence of transactions, in which each transaction
is invoked from outside the system (actors) and engages internal objects to interact with
one another and with the systems surroundings.
Fig: Use case diagram for Alumni Association System

Registrat
ion
Login
Login
Post
Post a
a
Query
Query
View
View
queries
queries
student

My
My
queries
queries

Login
table
Query
Query
table
table
solutions
solutions

mail
Edit
mail
Edit
profile
profile
Change
Change
pass
pass

Logout
Logout

Registration :
This usecase is responsible for providing registration form to fill the student
registration details.
Login :

Department of Computer Science and Engineering ,UVCE.


Page-31

STUDY FORUM
This usecase is responsible for providing the login page to read user name and
password to authenticate alumni.
Post a query :
This use-case comprises activities responsible for posting the queries.
View queries :
This usecase is responsible for display all the queries in the database posted by
different users.
My queries :
This usecase is responsible for display all the queries in the database posted by
particular user.
Edit Profile :
This usecase is responsible to update personal information.
Change password :
This usecase is responsible to changing the password.
Logout :
This use-case is responsible to exit from the forum.

4.2 Actors and their tasks in the system:


Student :

Registration

Login

Posting a query

View queries

My queries

Edit profile

Change password

Logout

Department of Computer Science and Engineering ,UVCE.


Page-32

STUDY FORUM

4.3 Presentation Model


This model defines how the control flows from one page to another page. The
following figure shows an abstract of all the major pages.
Index page

Registration

Student
Login page

Home page

Posting a
query
View queries
My queries
Edit
profile
Change pswd
Logout
Department of Computer Science and Engineering ,UVCE.
Page-33

STUDY FORUM
4.4 Service Model
This model comprises the definition of the business processes supplied by the
application along with the operations needed to be implement. The following diagram
shows operations related to Study Forum System.

New student registration :process


New
student
Enter user
name&password
Enter dob,mailid,sub,ph
no

View and answer Queries: process


View and answer
Queries

List all queries

List specific user


queries

View Selected query witanswer

Answer the
query

Department of Computer Science and Engineering ,UVCE.


Page-34

STUDY FORUM
Post query: process
Post query
Select
subject
Submit
query

4.5 Database Design


Login
User
name

Password

FullName

Dob

Sub
interested

Phone

Title

Sub ject

query

Session
sid

User name

Queries
qnum

User name Date of post

Solutions
qnum

User name

Solution

Department of Computer Science and Engineering ,UVCE.


Page-35

Email

STUDY FORUM
Chapter 5

Implementaion
MySQL database connection:
MySQL is currently the most popular open source database server in existence. It is very
commonly used in conjunction with PHP scripts to create powerful and dynamic server-side
applications.

Creating database
MySQL database is a way of organizing a group of tables. If you were going to create
a bunch of different tables that shared a common theme, you would group them into one
database to make the management process easier. Most web hosts do not allow you to create a
database directly through a PHP script. Instead they require that you use the PHP/MySQL
administration tools on the web host control panel to create these databases. Create a database
and assign a new user to this database. For all of our beginning examples we will be using the
following information

Server - localhost

Database - student

Username root

Password

The following command is used to create and use MySQL database for table creation and
querying on tables.
mysql> create database student
mysql>use student

PHP & MySQL Code to connect database:


<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
echo "Connected to MySQL";
?>
Department of Computer Science and Engineering ,UVCE.
Page-36

STUDY FORUM
Choosing the working database
After establishing a MySQL connection with the code above, you then need to choose which
database

you

will

be

using

with

this

connection.

This

is

done

the mysql_select_db function.


<?php
mysql_connect("localhost", "root", " ") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("student") or die(mysql_error());
echo "Connected to Database";
?>

AJAX
AJAX stands for Asynchronous JavaScript and XML. In a nutshell, it is the use of the
XMLHttpRequest object to communicate with server-side scripts. It can send as well as
receive information in a variety of formats, including JSON, XML, HTML, and even text
files. This lets you update portions of a page based upon user events.
The two features in question are that you can:

Make requests to the server without reloading the page


Receive and work with data from the server

How to make an HTTP request


var httpRequest;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

Handling the server response


if (httpRequest.readyState === 4) {
// everything is good, the response is received
} else {

Department of Computer Science and Engineering ,UVCE.


Page-37

with

STUDY FORUM
// still not ready
}

Creating Dynamic pages using PHP


PHP is probably the most popular scripting language on the web. It is used to enhance
web pages. With PHP, you can do things like
create username and password login pages, check details from a form, create forums,
picture galleries, surveys, and a whole lot more. The most popular explanation of just what
PHP stands for is "Hypertext Pre-processor".
PHP is known as a server-sided language. That's because the PHP doesn't get executed
on your computer, but on the computer you requested the page from. The results are then
handed over to you, and displayed in your browser. Other scripting languages you may have
heard of are ASP, Python and Perl. PHP is a web scripting language which means it was
designed to work with HTML. You can easily embed PHP code into your HTML code.

The above figure shows the basic php diagram which illustrates the process of php
script execution to load dynamic pages to browser. The PHP module executes the script,
which then sends out the result in the form of HTML back to your browser, which you see on
the screen.
When writing php code, you enclose your PHP code in special php tags. This tells the
browser that we're working with PHP. See below.
<?php
Department of Computer Science and Engineering ,UVCE.
Page-38

STUDY FORUM
//your php code goes here
?>

Now let see how we blend PHP and HTML together.


<html>
<title>my php page</title>
<body>
<?php
echo "hello there!";
?>
</body>
</html>

The following php scripts are written for our Study Forum web application
Index.php:It is a first page in our web application, which includes some information regarding
study forum as well as some frequently asked questions.
Register.php:The php script which displays the form to read student information like name,
password, date of birth, mail id, etc.. for new student registration. This page included ajax
code to validate username which is unique.
paq.php:This script is responsible for displaying user interface to post a query.It displays user
interface along user name and date of post.Here one text box is provided to enter query.
Paqregister.php:This script is responsible for reading form data of paq.php and storing the data into
data base table.
Auth.php:Department of Computer Science and Engineering ,UVCE.
Page-39

STUDY FORUM
This script creates a session for the login user after successful login. The session is
created with session variable ses_user, which holds the user name of the login student.

Login.php:This script is called by login form of login.html page, it includes database query to
check whether the given login name and password is correct or not.
Home.php:This scripts appears web page only for the logged in student, its a home page for
study forum. It displays options like post a query, view queries, my queries, edit profile,
change password, frequently answered queries,and logout.
Allquery.php:The scripts written in this page are responsible for retrieving all queries in the
database and display those queries along with sent user name, date of posting ,and query title.
Answer.php:This script displays complete query and its available answers. It dispays text box to
post new for the same question. The entered answer is stored in to the data base.
Edit profile.php:This script displays the profile of logged in student to edit his/her profile information .
Editregister.php:This script is used to read the edited details from the form and to store in to the
database.
changepass.php:This script dispalys user interface to change the password.
Passregister.php:This script read new password and old password from the form and update password
field in the database.

Department of Computer Science and Engineering ,UVCE.


Page-40

STUDY FORUM
fanswer.php:This script is responsible for retrieving and displaying of frequently answered queries,
and their answers.

Myquery.php:This script provides all queries submitted by the login user along with date of
posting , query title and no.of answers available for that query.
Checkuname.php:This script checks whether the the entered user name is available to this user or used
by some other user.
Session.php:This script creates a session for login user.
faiq.php:This script displays frequently asked interview questions in different subjects as well
as some interesting questions also.
Logout.php:When this script is executed it deletes the current session of the student and redirect
student to the index page.
databaseconnection.php:This page is included php statements to establish connection between php script and
MySQL database.

Department of Computer Science and Engineering ,UVCE.


Page-41

STUDY FORUM

Chapter 6

Testing
Software testing is the most critical phase in the development life cycle. Testing
performs a very critical role for quality assurance and ensuring the reliability of the software.
Software testing represents the ultimate review of specification design and preview.
During the development of software, errors can be injected at any stage. However,
requirements and design errors are likely to remain undetected. Those errors will be
ultimately reflected in the code. During testing, the program to be tested is executed with a
set of test cases and output of program for test cases are evaluated to describe program
performance to expected level. No system design is perfect. Since, communication problem,
programmers negligence or constraints create errors that must be eliminated before the
system is ready for user acceptance.
The common view of testing by user is that it is performed to prove that there are no
errors in a program. The common view of testing by user is that it is performed to prove that
there are no errors in a program. However, it is virtually impossible, since analyst cannot
prove that software is free and clear of all errors. A successful test is one that finds an error.
Reliability is to be designed in to the system.
Various testing strategies
A strategy for the software testing may be viewed a spiral which constitutes the following.
i.

Unit Testing.

ii.

Integration Testing.

6.1 Unit Testing


Department of Computer Science and Engineering ,UVCE.
Page-42

STUDY FORUM
This is the first level of testing, where different modules are tested against the
specification product during design of the modules. Unit testing is essentially for verification
of the code produced during the coding phase and hence the goal is to test the internal logic
of the modules.
Unit testing checks two types of errors syntax and logic. The testing can be
performed by the Bottom-Up ,which starts at the smallest and lowest level of modules and
proceeding one at a time or Top-Down testing , where testing begins with the upper test of
modules and moves towards the smaller ones.
Executing and viewing each php script after development through which we develop
this web application page by page. All these pages and hyper links have worked properly for
syntax and logic. This testing focuses verification, effort on smaller unit of software design.
This testing was carried out during coding and tested results are compared with expected
output.
In our project: unit testing we started from MySQL queries after creating database
and required tables. The values for the tables are inserted manually by executing in command
mode and some queries also executed to retrieve the record from the table.
All javascript functions which are used to validate the input data are tested by giving
random data to all the fields whenever they have been opened. The important thing w.r.t
javascript is some browsers will not support to execute javascript if the users disable
javascript in their browser.
Similarly, all individual php scripts are also executed by viewing their output on
several times with random input data. The php runs in server side therefore no need to worry
about browser compatibility or configuration.

6.2 Integrated Testing


Integration testing is the systematic technique for constructing the program structure
while at the same time conducting test to uncover errors associated with interface. The
objective is to take unit testing modules and build the program structure that has been
dictated by design. All modules are combined in this testing step. Then the entire program is
tested as a whole.
Department of Computer Science and Engineering ,UVCE.
Page-43

STUDY FORUM
In the integration testing, many tested modules are combined into subsystem, which
are then tested. The goal is to see integrated property of modules. The emphasis is being on
testing interface between modules. This testing activity can be considered as testing design.
In our Project: After connecting all web pages with database system, the integrated
system is tested by giving legitimate inputs. Some Ajax scripts are executed at Integration
testing because we need to execute with two or more php scripts. The integration was easier
in our project but, testing after integration takes more time to test the system. Because web
application means it included with more links and more scripts to be executed and also we
cant expect the navigation of the web page from the user. Finally, the system was tested by
many of my friends to detect bugs and make the system more reliable.

Department of Computer Science and Engineering ,UVCE.


Page-44

STUDY FORUM

Chapter 7

Conclusion
The web application Study Forum is implemented as an application of WEB-2.0
Technologies. This application has been developed using PHP, MySQL, JAVA-Script, AJAX,
HTML and Cascading Style Sheets. The main goal of the project has been achieved with the
help of above mentioned technologies. The project is supporting in most of the standard
browsers. All the mentioned requirements of the Study Forum has been satisfied and tested
all the operations by navigating the webpages.

Future works

Providing online solutions to the queries from the expert groups.

Planning to provide e-books and video tutorials.

Ranking the students by testing their knowledge through online exams.

Department of Computer Science and Engineering ,UVCE.


Page-45

STUDY FORUM

SNAPSHOTS

Department of Computer Science and Engineering ,UVCE.


Page-46

STUDY FORUM

Department of Computer Science and Engineering ,UVCE.


Page-47

STUDY FORUM

Department of Computer Science and Engineering ,UVCE.


Page-48

STUDY FORUM

Department of Computer Science and Engineering ,UVCE.


Page-49

STUDY FORUM

Bibliography
1. Opensource Web development using LAMPP James Lee, Brent Ware
2. Teach Yourself Javascript Third Edition by SAMS
3.

Database systems by Elmarsi Navate.

PHP and MySQL

www.homeandlearn.co.uk/php/php.html

http:/ /www.php-learn-it.com/index.html

http://www.php-scripts.com

www.tizag.com/index.html

www.w3schools.com

JAVA Script

www.pageresource.com/jscript/index4.htm

http://www.java-samples.com/javascript/index.html

http://www.javascriptkit.com

AJAX

http://developer.mozilla.org/en/ajax.html

http://onlamp.com/xmlhttprequest.html

http://www.java-samples.com/ajax/index.html

HTML & CSS

http://www.w3schools.com

www.htmlcodetutorial.com/quicklist.html

http://www.java-samples.com/ajax/index.html

Department of Computer Science and Engineering ,UVCE.


Page-50

STUDY FORUM

Department of Computer Science and Engineering ,UVCE.


Page-51

Vous aimerez peut-être aussi