Web Development Using PHP
Web Development Using PHP
Web Development Using PHP
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.
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.
On the server side, Web 2.0 uses many of the new languages such as
PHP
Ruby
ColdFusion
Perl
Python
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
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;
?>
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");
?>
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)
$expire - time (in UNIX timestamp) when the cookie will expire. Example: time()
+"3600". Cookie is set to expire after one hour.
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.
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.
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.
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.
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
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.
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:
A function name
Defining a Function
function popupalert()
{
alert('This is an alert box.');
}
Calling a Function
<A HREF="#top" onClick="anotherAlert('top')">top</A>
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
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
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
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:
Calling the constructor function of the RegExp object, as in: re = new RegExp("ab+c")
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-
STUDY FORUM
*
(The decimal point) matches any single character except the newline
character.
(x)
x|y
{n}
{n,}
{n,m}
[xyz]
A character set. Matches any one of the enclosed characters. You can
specify a range of characters by using a hyphen.
[^xyz]
[\b]
\b
AJAX
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.
By using asynchronous process user can send a request without waiting fot previous
response. The following figure shows how AJAX works
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
responseXML
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;
Description
readyState
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;
}
}
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>.
STUDY FORUM
*<CENTER>tag:The center tags are commonly used,but they are not part of the
HTML standard.
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>
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.
Interfaces are user friendly forms so user must able to choose appropriate option
for prompted messages.
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.
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.
STUDY FORUM
3.2.2 Non functional requirements:
Security : System should provide both user level and Network level security.
TIME SCHEDULE
STUDY FORUM
Processor
RAM
128MB
40GB
Software requirements
Client system
Operating System
Browser
Server system
Operating System
Web Server
Database server
MySQL server
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 :
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.
Registration
Login
Posting a query
View queries
My queries
Edit profile
Change password
Logout
STUDY FORUM
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.
Answer the
query
STUDY FORUM
Post query: process
Post query
Select
subject
Submit
query
Password
FullName
Dob
Sub
interested
Phone
Title
Sub ject
query
Session
sid
User name
Queries
qnum
Solutions
qnum
User name
Solution
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
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
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:
with
STUDY FORUM
// still not ready
}
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
?>
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.
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.
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.
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.
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.
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
STUDY FORUM
SNAPSHOTS
STUDY FORUM
STUDY FORUM
STUDY FORUM
STUDY FORUM
Bibliography
1. Opensource Web development using LAMPP James Lee, Brent Ware
2. Teach Yourself Javascript Third Edition by SAMS
3.
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
http://www.w3schools.com
www.htmlcodetutorial.com/quicklist.html
http://www.java-samples.com/ajax/index.html
STUDY FORUM