web development using php
TRANSCRIPT
-
8/19/2019 web development using php
1/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++,D! "#! ,etc$ %n the Study Forum we can get the best
solutions to the queries$ %n Forum the students who are already registered can login and then
&ost the queries$ !he students who know the answers to the queries they can &ost the answers$
For a single query we can get many answers also$ 'ere we will get the most im&ortant questions
which are asked (requently in many interviews$
%n this (orum we may get the answers (rom e)&erts in that area$ !his Forum is a user
(riendly (orum so that users can &ost the queries easily and as well as they can get answers$
From this Forum students can learn technologies easily $So by *oining in the Forum we can
share the knowledge (rom others$
!o Develo& the Study Forum % used S-., '!., AJA/, JavaScri&t, Cascading
Style Sheets and 0'0 scri&ting language during the develo&ment &hase$ Front1end is the 2eb1 based %nter(ace (or all users$ S-. and 0'0 are (riendly develo&ment tools used (or the
back1end database and &ro*ect develo&ment$
%n the introduction, % have &resented necessity o( Study Forum, and the basic o&erations$
!he .iterature survey includes the brie( introduction about the web 3$4 technologies and how to
ado&t those technologies$ !he .iterature survey gives correct synta) (or beginners to start
learning the technology$ !he cha&ter15 illustrates the requirements o( the system$ !hese
requirements are classi(ied into Functional requirements and non1Functional requirements$
Cha&ter16 describes the design o( Study Forum System, it contains use1case diagram,
&resentation diagram, &rocess diagrams and database structure$ !he cha&ter17 include the
im&lementation &art, here % e)&lained all the &h& scri&ts in abstract and 0'0 yS-.
connection$ !he cha&ter18 tells about com&lete testing &art, which includes both unit testing and
integration testing$ Finally, % have &rinted sna&shots, which are im&ortant &ages in this System$
Department of Computer Science and Engineering ,UVCE.
Page-
-
8/19/2019 web development using php
2/51
STUDY FORUM
Chapter 2
Literature SurveyIntroduction to WEB 2.0
!he term 2eb 3$4 is associated with web a&&lications that (acilitate &artici&atory
in(ormation sharing, intero&erability, user1centered design, and collaboration on the 2orld
2ide 2eb$ A 2eb 3$4 site allows users to interact and collaborate with each other in a social
media dialogue as creators 9 &roducers: o( user1generated content in a virtual community, in
contrast to websites where users 9consumers: are limited to the &assive viewing
o( content that was created (or them$ #)am&les o( 2eb 3$4 include social networking
sites, blogs, wikis, video sharing sites, hosted services ; web a&&lications$
2eb 3$4 websites allow users to do more than *ust retrieve in(ormation$ $4=, they &rovide the user with more user1inter(ace,
so(tware and storage (acilities, all through their browser$ !his has been called ="etwork as
&lat(orm= com&uting$ ?sers can &rovide the data that is on a 2eb 3$4 site and e)ercise some
control over that data$ !hese sites may have an =Architecture o( &artici&ation= that
encourages users to add value to the a&&lication as they use it$
• !he client1side@web browser technologies used in 2eb 3$4 develo&ment are
• Asynchronous JavaScri&t and /. 9A*a):,
• Adobe Flash and the Adobe Fle) (ramework,
• JavaScri&t@A*a) (rameworks such as ahooB ?% .ibrary, Do*o !oolkit, oo!ools,
and *-uery$
n the server side, 2eb 3$4 uses many o( the new languages such as
• 0'0
• uby
• ColdFusion
• 0erl
• 0ython
• JS0 and AS0
Department of Computer Science and Engineering ,UVCE.
Page-!
http://en.wikipedia.org/wiki/Information_sharinghttp://en.wikipedia.org/wiki/Interoperabilityhttp://en.wikipedia.org/wiki/User-centered_designhttp://en.wikipedia.org/wiki/Collaborationhttp://en.wikipedia.org/wiki/World_Wide_Webhttp://en.wikipedia.org/wiki/World_Wide_Webhttp://en.wikipedia.org/wiki/Social_mediahttp://en.wikipedia.org/wiki/Social_mediahttp://en.wikipedia.org/wiki/Prosumershttp://en.wikipedia.org/wiki/User-generated_contenthttp://en.wikipedia.org/wiki/Virtual_communityhttp://en.wikipedia.org/wiki/Consumerhttp://en.wikipedia.org/wiki/Content_(media_and_publishing)http://en.wikipedia.org/wiki/Social_networking_sitehttp://en.wikipedia.org/wiki/Social_networking_sitehttp://en.wikipedia.org/wiki/Bloghttp://en.wikipedia.org/wiki/Wikihttp://en.wikipedia.org/wiki/Video_sharinghttp://en.wikipedia.org/wiki/Web_servicehttp://en.wikipedia.org/wiki/Web_applicationhttp://en.wikipedia.org/wiki/Web_1.0http://en.wikipedia.org/wiki/Web_operating_systemhttp://en.wikipedia.org/wiki/Web_operating_systemhttp://en.wikipedia.org/wiki/Client-sidehttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Ajax_(programming)http://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flexhttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Yahoo!_UI_Libraryhttp://en.wikipedia.org/wiki/Dojo_Toolkithttp://en.wikipedia.org/wiki/MooToolshttp://en.wikipedia.org/wiki/JQueryhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Ruby_(programming_language)http://en.wikipedia.org/wiki/ColdFusionhttp://en.wikipedia.org/wiki/Perlhttp://en.wikipedia.org/wiki/Python_(programming_language)http://en.wikipedia.org/wiki/Java_Server_Pageshttp://en.wikipedia.org/wiki/Active_Server_Pageshttp://en.wikipedia.org/wiki/Active_Server_Pageshttp://en.wikipedia.org/wiki/Information_sharinghttp://en.wikipedia.org/wiki/Interoperabilityhttp://en.wikipedia.org/wiki/User-centered_designhttp://en.wikipedia.org/wiki/Collaborationhttp://en.wikipedia.org/wiki/World_Wide_Webhttp://en.wikipedia.org/wiki/World_Wide_Webhttp://en.wikipedia.org/wiki/Social_mediahttp://en.wikipedia.org/wiki/Social_mediahttp://en.wikipedia.org/wiki/Prosumershttp://en.wikipedia.org/wiki/User-generated_contenthttp://en.wikipedia.org/wiki/Virtual_communityhttp://en.wikipedia.org/wiki/Consumerhttp://en.wikipedia.org/wiki/Content_(media_and_publishing)http://en.wikipedia.org/wiki/Social_networking_sitehttp://en.wikipedia.org/wiki/Social_networking_sitehttp://en.wikipedia.org/wiki/Bloghttp://en.wikipedia.org/wiki/Wikihttp://en.wikipedia.org/wiki/Video_sharinghttp://en.wikipedia.org/wiki/Web_servicehttp://en.wikipedia.org/wiki/Web_applicationhttp://en.wikipedia.org/wiki/Web_1.0http://en.wikipedia.org/wiki/Web_operating_systemhttp://en.wikipedia.org/wiki/Web_operating_systemhttp://en.wikipedia.org/wiki/Client-sidehttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Ajax_(programming)http://en.wikipedia.org/wiki/Adobe_Flashhttp://en.wikipedia.org/wiki/Adobe_Flexhttp://en.wikipedia.org/wiki/JavaScripthttp://en.wikipedia.org/wiki/Yahoo!_UI_Libraryhttp://en.wikipedia.org/wiki/Dojo_Toolkithttp://en.wikipedia.org/wiki/MooToolshttp://en.wikipedia.org/wiki/JQueryhttp://en.wikipedia.org/wiki/PHPhttp://en.wikipedia.org/wiki/Ruby_(programming_language)http://en.wikipedia.org/wiki/ColdFusionhttp://en.wikipedia.org/wiki/Perlhttp://en.wikipedia.org/wiki/Python_(programming_language)http://en.wikipedia.org/wiki/Java_Server_Pageshttp://en.wikipedia.org/wiki/Active_Server_Pages
-
8/19/2019 web development using php
3/51
STUDY FORUM
are used to dynamically out&ut the data using in(ormation (rom (iles and databases$
PHP
0'0 stands (or =0'0 'y&er!e)t 0re&rocessor=$ 0'0 is a server side scri&ting
language (or making logic driven websites$ %t is used to enhance web &ages$ 2ith 0'0, you
can do things like create username and &assword login &ages, check details (rom a (orm,
create (orums, &icture galleries, surveys, and a whole lot more$ 0'0 doesnt get e)ecuted on
your com&uter, but on the com&uter you requested the &age (rom$ !he results are then handed
over to you, and dis&layed in your browser$ ther scri&ting languages you may have heard o(
are JS0, AS0, 0ython and 0erl$
!here are two so(twares available (or develo&ing a&&lication in &h&
>$ 2am&& 92indows a&ache mysql &h& and &erl:
3$ /am&& 9/ml a&ache mysql &h& and &erl:
0'0s synta) and semantics are similar to most other &rogramming languages 9C, Java, 0erl:
with the addition that all 0'0 code is contained with a tag, o( sorts$ All 0'0 code must be
contained within the (ollowing$$$
PHP Code:
E&h&
@@0'0 code here
G
or the shorthand 0'0 tag that requires shorthand su&&ort to be enabled on your server$$$
E
@@0'0 code here
G
%( you have 0'0 inserted into your '!. and want the web browser to inter&ret it correctly,
then you must save the (ile with a .php e)tension, instead o( the standard .html e)tension$
PHP : Variabe!
Department of Computer Science and Engineering ,UVCE.
Page-"
-
8/19/2019 web development using php
4/51
STUDY FORUM
Variables are used (or storing a values, like te)t strings, numbers or arrays$ 2hen a variable
is declared, it can be used over and over again in your scri&t$ All variables in 0'0 start with a
H sign symbol$ !he correct way o( declaring a variable in 0'0
HvarIname valueK
"ew 0'0 &rogrammers o(ten (orget the H sign at the beginning o( the variable$ %n that case it
will not work$
A (unction is *ust a segment o( code, se&arate (rom the rest o( your code$
(unction (unctionIname9 : L
M
So you start by ty&ing the word (unction$ ou then need to come u& with a name (or your
(unction$
Function dis&layIerrorImessage9:L
Department of Computer Science and Engineering ,UVCE.
Page-#
-
8/19/2019 web development using php
5/51
STUDY FORUM
&rint =#rror Detetceted=K
M
Strin" #unction!
$he !trin" %unction! ao& you to 'anipuate !trin"!.
Concatenatin" Strin"! in PHP
%n 0'0, dot 9$: o&erator is used to concatenate two or more strings together to (orm a single
string$ E&h&
Hstr> =% .ove 0'0$=K
Hstr3 =0'0 is (un to learn$=K
echo Hstr>$= =$Hstr3K
G
E!capin" (uote! &ith in (uote!
E&h&
Hstr =N=!his is a 0'0 string e)am&les in double quotesN==K
echo HstrK
G
)!e%u PHP Strin" #unction!
!tren*+: !his (unction returns the number o( characters in a string$
!tr,repace*+: !his (unction re&laces all occurrences o( the search string in the main string
with the re&lace string$
E&h&
Hstr ='elloB 'ow are you today=K
echo strIre&lace9='ello=, ='i=, Hstr:K
G
tri'*+: !his (unction removes whites&ace (rom the beginning and (rom the end o( the string$
!trtoupper*+: !his (unction converts all lower case letters to u&&er$
uc%ir!t*+: !his (unction changes the (irst letter in the string to u&&er case$
Department of Computer Science and Engineering ,UVCE.
Page-$
-
8/19/2019 web development using php
6/51
STUDY FORUM
Wor-in" &ith #ie! in PHP
ani&ulating (iles is a basic necessity (or serious &rogrammers and 0'0 gives you a
great deal o( tools (or creating, u&loading, and editing (iles$
A better method to o&en (iles is with (o&en9 :$ !his (unction gives you more o&tions that, such
as setting whether the (ile is (or read only, (or writing to as well, and a (ew more
o&tions$
E&h&
H(h (o&en9=my(ile$t)t=, =r=:K
i(9H(h(alse:
die9=unable to create (ile=:K
G
!he one well start with is read(ile9 :$ As its name suggest, it reads the contents o( a (ile$
E0'0
H(ileIcontentsread(ile9=dictionary$t)t=:K
&rint H(ileIcontentsK
G
open %ie %or readin" and &ritin"
E&h&
H(h (o&en9= my(ile$t)t=, =r+=:K
i(9H(h(alse:
die9=unable to create (ile=:K
G
Department of Computer Science and Engineering ,UVCE.
Page-%
-
8/19/2019 web development using php
7/51
STUDY FORUM
PHP Sessions
Sessions are used to store in(ormation which can be used through1out the a&&lication
(or the entire time the user is logged in or running the a&&lication$ #ach time a user visits
your website, you can create a session (or that user to store in(ormation &ertaining to that
user$
?nlike other a&&lications, in web a&&lications, all the stored variables and ob*ects are
not globally available throughout all &ages 9unless sent through 0S! or O#! methods to the
ne)t &age:, so to tackle this &roblem sessions are utiliPed$
-
8/19/2019 web development using php
8/51
STUDY FORUM
echo =Ebr@G=K
echo HIS#SS%"Q=color=RK
G
Coo-ie
Cookie is a small (lat (ile which sits on users com&uter, is o(ten used to store data
which can be used to identi(y a user, (or e)am&le, &ersons username$ A cookie can be created
using the setcookie9: (unction in 0'0$
setcookie9Hname, Hvalue, He)&ire, H&ath, Hdomain, Hsecure:
• Hname 1 name o( the cookie$ #)am&le =username=
• Hvalue 1 value o( the cookie$ #)am&le =*ohn=
• He)&ire 1 time 9in ?"%/ timestam&: when the cookie will e)&ire$ #)am&le time9:
+=5844=$ Cookie is set to e)&ire a(ter one hour$
•
H&ath 1 &ath on the server where cookie will be available$E&h&
setcookie9=username=, =*ohn=, time9:+984T84T36T587::K
G
Cookie in(ormation can retrieved using the &rede(ined HICU%# array$
E&h& echo HICU%#Q=username=RK G
/ate*+ %unction
!he 0'0 date9: (unction is used to (ormat a time and@or date$
!he 0'0 date9: (unction (ormats a timestam& to a more readable date and time$
A timestam& is a sequence o( characters, denoting the date and@or time at which a certain
event occurred$
Synta
Department of Computer Science and Engineering ,UVCE.
Page-'
-
8/19/2019 web development using php
9/51
STUDY FORUM
date9(ormat,timestam&:
format 1 !he (irst &arameter, (ormat, in the date (unction s&eci(ies how to dis&lay thedate@time$ %t uses di((erent letters to re&resent the date and time$ Some o( the letters used
above are described here$
• d 1 !he day o( the month, i$e$ 4>15>
• m 1 onth re&resentation in numbers, i$e$ 4>1>3
• 1 ear in (our digits
Dis&laying dates in di((erent (ormats$
E&h&
echo date9=1m1d=:K
echo date9=@m@d=:K
echo date9= d, =:K
echo date9=F d, =:K
echo date9=D d, =:K
echo date9=l F d, =:K
echo date9=l F d, , his=:K
echo date9=l F d, , hi A=:K
G
utput
34>>147143
34>>@47@43
ay 43, 34>>ay 43, 34>>
date and time on ay 43, 34>>
onday ay 43, 34>>
onday ay 43, 34>>, 4>3463
onday ay 43, 34>>, 4>34 A
timestamp &tional, S&eci(ies a timestam&$ De(ault is the current
Department of Computer Science and Engineering ,UVCE.
Page-(
-
8/19/2019 web development using php
10/51
STUDY FORUM
3S4L
yS-. is currently the most &o&ular o&en source database server$ %t is very
commonly used in con*unction with 0'0 scri&ts to create &ower(ul and dynamic server1side
a&&lications$ yS-. is a relational database$ A database is a structure that comes in two
(lavors
#at databa!e : Flat database that are *ust stored on hard drives like a te)t (ile$
eationa databa!e: A relational database is much more oriented to the human mind and is
o(ten &re(erred over the gabble1de1gook %n a relational structured database there are tables
that store data$ !he columns de(ine which kinds o( in(ormation will be stored in the table$
'y!( connect : 2hen the 0'0 scri&t and yS-. are on the same machine, you can use
localhost as the address you wish to connect to$ localhost is a shortcut to *ust have the
machine connect to itsel($ %( your yS-. service is running at a se&arate location you will
need to insert the %0 address or ?. in &lace o( localhost $
Synta)
mysqlIconnect9servername,username,&assword:K
!erverna'e: &tional$ S&eci(ies the server to connect to$ De(ault value is =localhost5548=
u!erna'e : &tional$ S&eci(ies the username to log in with$ De(ault value is the name o( the
user that owns the server &rocess
pa!!&ord: &tional$ S&eci(ies the &assword to log in with$ De(ault is ==
-
8/19/2019 web development using php
11/51
STUDY FORUM
echo =Connected to yS-.Ebr @G=K
G
!he =or die9mysql$$$= code dis&lays an error message in your browser i( 11youve &robably
guessed it 11 there is an error in &rocessing the connection$
'y!(,co!e*+ :!he connection will be closed automatically when the scri&t ends$ !o close
the connection be(ore, use the mysqlIclose9: (unction$
Seect databa!e : A(ter establishing a yS-. connection with the code above, you then
need to choose which database you will be using with this connection$ !his is done with
the mysql_select_db 9:$
-
8/19/2019 web development using php
12/51
STUDY FORUM
• %"! 1 !his stands (or integer or whole number$ id has been de(ined to be an integer$
• "! "?.. 1 !hese are actually two keywords, but they combine together to say that
this column cannot be null$ An entry is "! "?.. only i( it has some value, while
something with no value is "?..$
• A?!I%"C##"! 1 #ach time a new entry is added the value will be incremented
by >$
• 0%A U# 9%D:10%A U# is used as a unique identi(ier (or the rows$ 'ere we
have made =id= the 0%A U# (or this table$ !his means that no two ids can be
the same$
2 "A# VAC'A954: 1 'ere we make a new column with the name =name=B
VAC'A stands (or =variable character=$ =Character= means that you can &ut in any
kind o( ty&ed in(ormation in this column 9letters, numbers, symbols, etc:$ %ts
=variable= because it can ad*ust its siPe to store as little as 4 characters and u& to a
s&eci(ied ma)imum number o( characters$
3 D%#9S-.I#9:: !his will &rint out an error i( there is a &roblem in the
table creation &rocess$
Insert Data Into a Database Table
4 When data i! put into a yS4L tabe it i! re%erred to a! in!ertin" data.
When in!ertin" data it i! i'portant to re'e'ber the eact na'e! and type! o% the
tabe5! cou'n!.
Synta)
%"S#! %"! tableIname VA.?#S 9value>, value3, value5,$$$:
!he second (orm is
%"S#! %"! tableIname 9column>, column3, column5,$$$:VA.?#S 9value>,
value3, value5,$$$:
retrievin" data &ith php 6 'y!(
Department of Computer Science and Engineering ,UVCE.
Page-!
-
8/19/2019 web development using php
13/51
STUDY FORUM
7 ?sually most o( the work done with yS-. involves &ulling down data (rom a
yS-. database$ %n yS-., data is retrieved with the =S#.#C!= keyword$
Hresult mysqlIquery9=select T (rom e)am&le=:
2hen you &er(orm a S#.#C! query on the database it will return a yS-. esource that
holds everything (rom your yS-. table, =e)am&le=$ 2e want to use this esource in our
0'0 code, so we need to store it in a variable, $result $
mysql_fetch_array 9: mysql_fetch_array() is actually a 0'0 (unction that allows you to
access data stored in the result returned (rom a success(ul mysql_query$ %( you have been
*um&ing around our yS-.$
%etch ro&! u!in" &hie oop:
E&h& @@ ake a yS-. Connection
Hquery =S#.#C! T F e)am&le=K
Hresult mysqlIquery9Hquery: or die9mysqlIerror9::K
while9Hrow mysqlI(etchIarray9Hresult::Lecho HrowQnameR$ = 1 =$ HrowQageRK M
G
S-. 2'##
2'## lets you s&eci(y requirements that entries must meet in order to be
returned in the yS-. result$ !hose entries that do not &ass the test will be le(t out$
Hresult mysqlIquery9=S#.#C! T F e)am&le 2'## nameSandy
Smith=: or die9mysqlIerror9::K
S-. 2%.DCAD ?SAO#
%n yS-. there is a =wildcard= character that can be used to search (or &artial
matches in your database$ !he tells yS-. to ignore the te)t that would normally a&&ear
in &lace o( the wildcard$ For e)am&le 3 would match the (ollowing 34, 37, 3444444)
Hresult mysqlIquery9=S#.#C! T F e)am&le 2'## age .%U# 3 =:
or die9mysqlIerror9::K
Department of Computer Science and Engineering ,UVCE.
Page-"
-
8/19/2019 web development using php
14/51
STUDY FORUM
S-. D#
-
8/19/2019 web development using php
15/51
STUDY FORUM
count countin" record!
!he C?"! (unction is an aggregate (unction that sim&ly counts all the items that are in agrou&$
Hquery =S#.#C! ty&e, C?"!9name: F &roducts O?0
-
8/19/2019 web development using php
16/51
STUDY FORUM
V7I7BLE
Variables are like storage units, they can store all kinds o( data$ ou can create variables to
hold values$ JavaScri&t is case1sensitive$
PE7$S
JavaScri&t has many di((erent o&erators such as assignment, com&arison, arithmetic and
logical ,bitwise, string and some s&ecial o&erators$
#)9C$I9S
Functions are one o( the (undamental building blocks in JavaScri&t$ A (unction is a JavaScri&t
&rocedure 11 a set o( statements that &er(orms a s&eci(ic task$
A (unction de(inition has these basic &arts
• !he (unction keyword
• A (unction name
• A comma1se&arated list o( arguments to the (unction in &arentheses
• !he statements in the (unction in curly braces L M
/e%inin" a #unction
%unction &o&u&alert9:
L
alert9!his is an alert bo)$:K
M
Cain" a #unction
EA '#F=Xto&= onClick=anotherAlert9to&:=Gto&E@AG
Department of Computer Science and Engineering ,UVCE.
Page-%
-
8/19/2019 web development using php
17/51
STUDY FORUM
W
-
8/19/2019 web development using php
18/51
STUDY FORUM
• math
• array
EVE9$ H79/LI98 I9 ;7V7SCIP$
#vents describe actions that occur as the result o( user interaction with any a&&lication$
!he &rocessing that is &er(ormed in res&onse to the occurrence o( an event is known as
Event handin"$
!he code that is e)ecuted when an event occurs is known as an Event hander$
%t is im&ortant to know that every event is associated with a se&arate event handler, which
can be either user de(ined or system de(ined$ !he association o( an event with its event
handler is through the event handling attributes o( the '!. tags$
!he (ollowing table summariPes the events de(ined by JavaScri&t along with the event
handling attributes$
Event name Event handling attribute
Used in
Abort onAbort Image
Blur onBLur select, text, text area
Change onChange select, text, text area
Click onClick button, checkbox, radio,
link, reset, submit, areaError onError image
Focus onFocus select, text, text area
Load onLoad window, image
Mouseover onMouseOver link, area
Mouseout onMouseOut link, area
eset oneset !orm
"elect on"elect text, text area
"ubmit on"ubmit !orm
#nload on#nload window
Department of Computer Science and Engineering ,UVCE.
Page-'
-
8/19/2019 web development using php
19/51
STUDY FORUM
e"uar Epre!!ion!
egular e)&ressions are &atterns used to match character combinations in strings$ %n
JavaScri&t, regular e)&ressions are also ob*ects$
!hese &atterns are used with the e)ec and test methods o( regular e)&ressions, and with the
match, re&lace, search, and s&lit methods o( String$
Creatin" a e"uar Epre!!ion
ou construct a regular e)&ression in one o( two ways
• ?sing an ob*ect initialiPer, as in re = /ab+c/
• Calling the constructor (unction o( the eg#)& ob*ect, as in re = new RegExp(ab+c!
Writin" a e"uar Epre!!ion Pattern
A regular e)&ression &attern is com&osed o( sim&le characters or a combination o( sim&le and
s&ecial characters, such as @abTc@$
!he (allowing table &rovides a com&lete list and descri&tion o( the s&ecial characters that can
be used in regular e)&ressions$
Charact
er
Meaning
N For c*aracter+ t*at are u+ua treated itera, indicate+ t*at t*e net
c*aracter i+ +pecia and not to /e interpreted itera.
For eampe, /b/ matc*e+ t*e c*aracter 0/0. 1 pacing a /ac2+a+* in front
of /, t*at i+ / u+ing /\b/, t*e c*aracter /ecome+ +pecia to mean matc*a 3ord /oundar. -or-
Y Matc*e+ /eginning of input or ine.
For eampe, /^A/ doe+ not matc* t*e 040 in 5an 4,5 /ut doe+ matc* it in
54n 4.5
H Matc*e+ end of input or ine.
For eampe, /t$/ doe+ not matc* t*e 0t0 in 5eater5, /ut doe+ matc* it in
5eat5
Department of Computer Science and Engineering ,UVCE.
Page-(
-
8/19/2019 web development using php
20/51
STUDY FORUM
T Matc*e+ t*e preceding c*aracter ) or more time+.
+ Matc*e+ t*e preceding c*aracter or more time+. E6ui7aent to {1,}.
For eampe, /a+/ matc*e+ t*e 0a0 in 5cand5 and a t*e a0+ in
5caaaaaaand.5
Matc*e+ t*e preceding c*aracter ) or time.
. 8T*e decima point9 matc*e+ an +inge c*aracter ecept t*e ne3ine
c*aracter.
89 Matc*e+ 00 and remem/er+ t*e matc*.
For eampe, :8foo9: matc*e+ and remem/er+ 0foo0 in 5foo /ar.5 T*e
matc*ed +u/+tring can /e recaed from t*e re+uting arra0+ eement+ ;
-
8/19/2019 web development using php
21/51
STUDY FORUM
Asynchronous JavaScri&t + /.> while not a technology in itsel(, is a term coined in
3447 by Jesse James Oarrett, that describes a =new= a&&roach to using a number o( e)isting
technologies together, including '!.or /'!., Cascading Style Sheets, JavaScri&t, !he
Document b*ect odel, /., /S.!, and the /.'tt&equest ob*ect$
• 7synchronous ;avaScri&t 7nd =.
• !echnology behind interactive web sites
yS&ace, 0ersonalised Ooogle 0age, Oail etc
• 0rovide smoother e)&erience than conventional web &ages
• "o need to re(resh the entire &age
• Sni&&ets o( in(ormation are u&dated as necessary
-
8/19/2019 web development using php
22/51
STUDY FORUM
he !"#ttp%equest &b'ect
All modern browsers su&&ort the /.'tt&equest ob*ect 9%#7 and %#8 uses an
Active/b*ect:$
!he /.'tt&equest ob*ect is used to e)change data with a server behind the scenes$ !his
means that it is &ossible to u&date &arts o( a web &age, without reloading the whole &age$
Synta) (or creating an /.'tt&equest ob*ect
ariablenew /.'tt&equest9:K
Send a %equest o a Serer
!o send a request to a server, we use the o&en9: and send9: methods o( the /.'tt&equest
ob*ect
)mlhtt&$o&en9=O#!=,=a*a)Iin(o$t)t=,true:K
)mlhtt&$send9:K
Serer %esponse
!o get the res&onse (rom a server, use the res&onse!e)t or res&onse/. &ro&erty o( the
/.'tt&equest ob*ect$
Property Description
re+pon+eTet get t*e re+pon+e data a+ a +tring
re+pon+eHMI get t*e re+pon+e data a+ HMI data
he responseext roperty
%( the res&onse (rom the server is not /., use the res&onse!e)t &ro&erty$
Department of Computer Science and Engineering ,UVCE.
Page-!!
-
8/19/2019 web development using php
23/51
STUDY FORUM
!he res&onse!e)t &ro&erty returns the res&onse as a string, and you can use it accordingly
*xample
document$get#lement
-
8/19/2019 web development using php
24/51
STUDY FORUM
*xample
m*ttp.onread+tatec*angefunction89
A
if 8m*ttp.readState# NN m*ttp.+tatu+!))9
A
document.getEement1d85mDi759.innerJTMIm*ttp.re+pon+eTet
B
B
H$L:*Hyper tet 'ar-up an"ua"e+
'!. is used to build an organiPations retail commerce website or develo& a
business1to1business solution to e)change data with trading &artners$ !he web1based user
inter(ace say a lot about the com&any, to customers or &artners$
'!. is a valuable and a common com&onent o( electronic commerce$
'!.1'y&er !e)t ark1u& .anguage is a tag based language, used to Zmark u Z
s&eci(ic &arts o( a 2eb &age (or dis&lay$
'!. is a used (or describing how &ages o( te)t ,gra&hics and other in(ormation are
organiPed, (ormatted and linked together$ !he =hy&er te)t= means te)t stored in electronic
(orm with cross1re(erence links between &ages$ !he term stands (or its ca&ability to link a te)t
or gra&hic hots&ot to other web &ages$ !his &ower(ul (eature called as the hy&er link is one o(
the main reasons why '!. was ado&ted as the language (or the web$
'!. can be de(ined as a tag1based language used to =marku&[ s&eci(ic &arts o( a
2eb &age (or dis&lay$
-
8/19/2019 web development using php
25/51
STUDY FORUM
!he
-
8/19/2019 web development using php
26/51
STUDY FORUM
TEC#"!#Gtag!he center tags are commonly used,but they are not &art o( the
'!. standard$
TED.Gtag!he de(inition list tags are used to creat a de(inition list$
TE'Gtag%( an horiPontal rule is tag is added to a &age,then the browser sim&ly
draws a line across the &age$
H$L#S
An '!. (orm is a section o( a document containing normal content, marku&,
s&ecial elements called controls 9checkbo)es, radio buttons, menus, etc$:, and labels on those
controls$ ?sers generally =com&lete= a (orm by modi(ying its controls 9entering te)t, selecting
menu items, etc$:, be(ore submitting the (orm to an agent (or &rocessing 9e$g$, to a 2eb
server, to a mail server, etc$:
'eres a sim&le (orm that includes labels, radio buttons, and &ush buttons 9reset the (orm or
submit it:
EF action=htt&@@somesite$com@&rog@adduser= method=&ost=G
E0G
E.A
-
8/19/2019 web development using php
27/51
STUDY FORUM
E@FG
Department of Computer Science and Engineering ,UVCE.
Page-!&
-
8/19/2019 web development using php
28/51
STUDY FORUM
Chapter ?
e(uire'ent! !peci%ication!equirements are the Constraints or Services that is e)&ected (rom the system$ !here
are two ty&es o( requirements$
• ?ser equirements$
• System equirements$
?.1 )!er re(uire'ent!
• Students should be able to do registration by &roviding required in(ormation and
also they have to manage their &ro(ile
• %nter(aces are user (riendly (orms so user must able to choose a&&ro&riate o&tion
(or &rom&ted messages$
?.2 Sy!te' re(uire'ent!:
?.2.1 #unctiona re(uire'ent!:
• Student registration System must su&&ort (or student registration and to edit their
&ro(ile inter(ace must be user (riendly$ System must &rovide &ro&er (orms (or
entering new stdent record with all (ields $
• 0osting query system must allow users to send queries o( di((erent ty&e o(
&rogramming languages $
• View queries system should able to dis&lay all queries along with user name and
date o( &osting$
• %nterview -uestions System should able to &rovide some (erequently asked
interview questions$
• Answering queries system should allow users to answer the query, on clicking
the query$
• Change &assword system should able &rovide an o&tion to change their &assword
(requently$
Department of Computer Science and Engineering ,UVCE.
Page-!'
-
8/19/2019 web development using php
29/51
STUDY FORUM
?.2.2 9on %unctiona re(uire'ent!:
•Security System should &rovide both user level and "etwork level security$
• 0ortability System should be &lat(orm inde&endent, su&&orts in all standard
browser$
• Scalability %t must su&&ort even i( multi&le alums connected concurrently$
• Availability System must be available to use in any time936/\:$
• 0er(ormance System &er(ormance must be e)cellent both in time com&le)ity
and s&ace com&le)ity$
• #asy to work System must &rovide dynamic ?ser %nter(ace (orms
$IE SCHE/)LE
Department of Computer Science and Engineering ,UVCE.
Page-!(
-
8/19/2019 web development using php
30/51
STUDY FORUM
?.? Hard&are and So%t&are e(uire'ent!:
Hard&are re(uire'ent!
• 0rocessor 0entium %%% onwards
• A >3]<
• 'ard disk s&ace 64O<
So%t&are re(uire'ent!
Cient !y!te'
&erating System 2indows 3444, 2indows1/0, 2indows1\
.inu)1 Fedora, andriva, ?buntu, etc
-
8/19/2019 web development using php
31/51
-
8/19/2019 web development using php
32/51
STUDY FORUM
!his usecase is res&onsible (or &roviding the login &age to read user name and
&assword to authenticate alumni$
Po!t a (uery :
!his use1case com&rises activities res&onsible (or &osting the queries$
Vie& (uerie! :
!his usecase is res&onsible (or dis&lay all the queries in the database &osted by
di((erent users$
y (uerie! :
!his usecase is res&onsible (or dis&lay all the queries in the database &osted by
&articular user$
Edit Pro%ie :
!his usecase is res&onsible to u&date &ersonal in(ormation$
Chan"e pa!!&ord :
!his usecase is res&onsible to changing the &assword$
Lo"out :
!his use1case is res&onsible to e)it (rom the (orum$
@.2 7ctor! and their ta!-! in the !y!te':
Student :
•
egistration
• .ogin
• 0osting a query
• View queries
• y queries
• #dit &ro(ile
• Change &assword
• .ogout
Department of Computer Science and Engineering ,UVCE.
Page-"!
-
8/19/2019 web development using php
33/51
STUDY FORUM
@.? Pre!entation ode
!his model de(ines how the control (lows (rom one &age to another &age$ !he
(ollowing (igure shows an abstract o( all the ma*or &ages$
Department of Computer Science and Engineering ,UVCE.
Page-""
Index page
Student
Login page
egistration
Posting a
"ie# !ueries
$dit
&ome page
Logout
My !ueries
Change ps#d
-
8/19/2019 web development using php
34/51
STUDY FORUM
@.@ Service ode
!his model com&rises the de(inition o( the business &rocesses su&&lied by the
a&&lication along with the o&erations needed to be im&lement$ !he (ollowing diagram
shows o&erations related to Study Forum System$
'e# student registration :process
"ie# and ans#er (ueries: process
Department of Computer Science and Engineering ,UVCE.
Page-"#
Ge3
+tudent
Enter do/,maiid,+u/,p*
no
Enter u+er
nameNpa++3ord
List all !ueries List speci%c user
!ueries
"ie# Selected !uery #itans#er
Ans#er the
!uery
"ie# and ans#er
(ueries
-
8/19/2019 web development using php
35/51
STUDY FORUM
Post !uery: process
@.A /ataba!e /e!i"n
Iogin
U+er
name
Pa++3ord FuGame Do/ Su/
intere+ted
P*one Emai
Se++ion
+id U+er name
Querie+
6num U+er name Date of po+t Tite Su/ >ect 6uer
Soution+
6num U+er name Soution
Department of Computer Science and Engineering ,UVCE.
Page-"$
Seect
+u/>ect
Po+t 6uer
Su/mit
6uer
-
8/19/2019 web development using php
36/51
STUDY FORUM
Chapter A
I'pe'entaion
yS4L databa!e connection:
yS-. is currently the most &o&ular o&en source database server in e)istence$ %t is very
commonly used in con*unction with 0'0 scri&ts to create &ower(ul and dynamic server1side
a&&lications$
Creating database
yS-. database is a way o( organiPing a grou& o( tables$ %( you were going to create
a bunch o( di((erent tables that shared a common theme, you would grou& them into one
database to make the management &rocess easier$ ost web hosts do not allow you to create a
database directly through a 0'0 scri&t$ %nstead they require that you use the 0'0@yS-.
administration tools on the web host control &anel to create these databases$ Create a database
and assign a new user to this database$ For all o( our beginning e)am&les we will be using the
(ollowing in(ormation
• Ser"er + localhost
• Database + student
• #serna$e , -root
• Password , -
!he (ollowing command is used to create and use yS-. database (or table creation and
querying on tables$
$%s&l' create database stdent
$%s&l'se stdent
0'0 ; yS-. Code to connect database
)*pp
$%s&l,connect(localost- root- ! or die($%s&l,error(!!.
eco Connected to %S01.
*'
Department of Computer Science and Engineering ,UVCE.
Page-"%
-
8/19/2019 web development using php
37/51
STUDY FORUM
Choosing the working database
A(ter establishing a yS-. connection with the code above, you then need to choose which
database you will be using with this connection$ !his is done with
the mysqlIselectIdb (unction$
)*pp
$%s&l,connect(localost- root- ! or die($%s&l,error(!!.
eco Connected to %S01)br /'.
$%s&l,select,db(stdent! or die($%s&l,error(!!.
eco Connected to Database.
*'
AJA/
AJA/ stands (or Asynchronous JavaScri&t and /.$ %n a nutshell, it is the use o( theXMLHttpRequest ob*ect to communicate with server1side scri&ts$ %t can send as well as
receive in(ormation in a variety o( (ormats, including JS", /., '!., and even te)t(iles$ !his lets you u&date &ortions o( a &age based u&on user events$
!he two (eatures in question are that you can
• ake requests to the server without reloading the &age
• eceive and work with data (rom the server
How to make an HTTP request
var httpRequest;
if (wi!"w#XMLHttpRequest { // M"&i''a, afari, ###
httpRequest ) ew XMLHttpRequest(;
} e'se if (wi!"w#A*tiveXbe*t { // -.
httpRequest ) ew A*tiveXbe*t(Mi*r"s"ft#XMLH00;
}
Handling the server response
if (httpRequest#rea!2tate ))) 3 {
// ever2thi4 is 4""!, the resp"se is re*eive!
} e'se {
Department of Computer Science and Engineering ,UVCE.
Page-"&
-
8/19/2019 web development using php
38/51
STUDY FORUM
// sti'' "t rea!2
}
Creatin" /yna'ic pa"e! u!in" PHP
0'0 is &robably the most &o&ular scri&ting language on the web$ %t is used to enhance
web &ages$ 2ith 0'0, you can do things like
create username and &assword login &ages, check details (rom a (orm, create (orums,
&icture galleries, surveys, and a whole lot more$ !he most &o&ular e)&lanation o( *ust what0'0 stands (or is ='y&erte)t 0re1&rocessor=$
0'0 is known as a server1sided language$ !hats because the 0'0 doesnt get e)ecuted
on your com&uter, but on the com&uter you requested the &age (rom$ !he results are then
handed over to you, and dis&layed in your browser$ ther scri&ting languages you may have
heard o( are AS0, 0ython and 0erl$ 0'0 is a web scri&ting language which means it was
designed to work with '!.$ ou can easily embed 0'0 code into your '!. code$
!he above (igure shows the basic &h& diagram which illustrates the &rocess o( &h&
scri&t e)ecution to load dynamic &ages to browser$ !he 0'0 module e)ecutes the scri&t,
which then sends out the result in the (orm o( '!. back to your browser, which you see on
the screen$
2hen writing &h& code, you enclose your 0'0 code in s&ecial &h& tags$ !his tells the
browser that were working with 0'0$ See below$
-
8/19/2019 web development using php
39/51
STUDY FORUM
//your php code goes here
?>
"ow let see how we blend 0'0 and '!. together$
my php page
!he (ollowing &h& scri&ts are written (or our Study Forum web a&&lication
Inde.php:
%t is a (irst &age in our web a&&lication, which includes some in(ormation regarding
study (orum as well as some (requently asked questions$
e"i!ter.php:
!he &h& scri&t which dis&lays the (orm to read student in(ormation like name,
&assword, date o( birth, mail id, etc$$ (or new student registration$ !his &age included a*a)
code to validate username which is unique$
pa(.php:
!his scri&t is res&onsible (or dis&laying user inter(ace to &ost a query$%t dis&lays user
inter(ace along user name and date o( &ost$'ere one te)t bo) is &rovided to enter query$
Pa(re"i!ter.php:
!his scri&t is res&onsible (or reading (orm data o( &aq$&h& and storing the data into
data base table$
7uth.php:
Department of Computer Science and Engineering ,UVCE.
Page-"(
-
8/19/2019 web development using php
40/51
STUDY FORUM
!his scri&t creates a session (or the login user a(ter success(ul login$ !he session is
created with session variable !e!,u!er, which holds the user name o( the login student$
Lo"in.php:
!his scri&t is called by login (orm o( login$html &age, it includes database query to
check whether the given login name and &assword is correct or not$
Ho'e.php:
!his scri&ts a&&ears web &age only (or the logged in student, its a home &age (or
study (orum$ %t dis&lays o&tions like &ost a query, view queries, my queries, edit &ro(ile,
change &assword, (requently answered queries,and logout$
7(uery.php:
!he scri&ts written in this &age are res&onsible (or retrieving all queries in the
database and dis&lay those queries along with sent user name, date o( &osting ,and query title$
7n!&er.php:
!his scri&t dis&lays com&lete query and its available answers$ %t dis&ays te)t bo) to
&ost new (or the same question$ !he entered answer is stored in to the data base$
Edit pro%ie.php:
!his scri&t dis&lays the &ro(ile o( logged in student to edit his@her &ro(ile in(ormation $
Editre"i!ter.php:
!his scri&t is used to read the edited details (rom the (orm and to store in to thedatabase$
chan"epa!!.php:
!his scri&t dis&alys user inter(ace to change the &assword$
Pa!!re"i!ter.php:
!his scri&t read new &assword and old &assword (rom the (orm and u&date &assword
(ield in the database$
Department of Computer Science and Engineering ,UVCE.
Page-#)
-
8/19/2019 web development using php
41/51
STUDY FORUM
%an!&er.php:
!his scri&t is res&onsible (or retrieving and dis&laying o( (requently answered queries,
and their answers$
y(uery.php:
!his scri&t &rovides all queries submitted by the login user along with date o(
&osting , query title and no$o( answers available (or that query$
Chec-una'e.php:
!his scri&t checks whether the the entered user name is available to this user or used
by some other user$
Se!!ion.php:
!his scri&t creates a session (or login user$
%ai(.php:
!his scri&t dis&lays (requently asked interview questions in di((erent sub*ects as wellas some interesting questions also$
Lo"out.php:
2hen this scri&t is e)ecuted it deletes the current session o( the student and redirect
student to the inde) &age$
databa!econnection.php:
!his &age is included &h& statements to establish connection between &h& scri&t andyS-. database$
Department of Computer Science and Engineering ,UVCE.
Page-#
-
8/19/2019 web development using php
42/51
STUDY FORUM
Chapter
$e!tin"
So(tware testing is the most critical &hase in the develo&ment li(e cycle$ !esting
&er(orms a very critical role (or quality assurance and ensuring the reliability o( the so(tware$
So(tware testing re&resents the ultimate review o( s&eci(ication design and &review$
During the develo&ment o( so(tware, errors can be in*ected at any stage$ 'owever,
requirements and design errors are likely to remain undetected$ !hose errors will be
ultimately re(lected in the code$ During testing, the &rogram to be tested is e)ecuted with a
set o( test cases and out&ut o( &rogram (or test cases are evaluated to describe &rogram
&er(ormance to e)&ected level$ "o system design is &er(ect$ Since, communication &roblem,
&rogrammers negligence or constraints create errors that must be eliminated be(ore the
system is ready (or user acce&tance$
!he common view o( testing by user is that it is &er(ormed to &rove that there are no
errors in a &rogram$ !he common view o( testing by user is that it is &er(ormed to &rove that
there are no errors in a &rogram$ 'owever, it is virtually im&ossible, since analyst cannot
&rove that so(tware is (ree and clear o( all errors$ A success(ul test is one that (inds an error$
eliability is to be designed in to the system$
Variou! te!tin" !trate"ie!
A strategy (or the so(tware testing may be viewed a s&iral which constitutes the (ollowing$
i$ ?nit !esting$
ii$ %ntegration !esting$
.1 )nit $e!tin"
Department of Computer Science and Engineering ,UVCE.
Page-#!
-
8/19/2019 web development using php
43/51
STUDY FORUM
!his is the (irst level o( testing, where di((erent modules are tested against the
s&eci(ication &roduct during design o( the modules$ ?nit testing is essentially (or veri(ication
o( the code &roduced during the coding &hase and hence the goal is to test the internal logic
o( the modules$
?nit testing checks two ty&es o( errors W synta) and logic$ !he testing can be
&er(ormed by the
-
8/19/2019 web development using php
44/51
STUDY FORUM
%n the integration testing, many tested modules are combined into subsystem, which
are then tested$ !he goal is to see integrated &ro&erty o( modules$ !he em&hasis is being on
testing inter(ace between modules$ !his testing activity can be considered as testing design$
In our Proect: A(ter connecting all web &ages with database system, the integrated
system is tested by giving legitimate in&uts$ Some A*a) scri&ts are e)ecuted at %ntegration
testing because we need to e)ecute with two or more &h& scri&ts$ !he integration was easier
in our &ro*ect but, testing a(ter integration takes more time to test the system$
-
8/19/2019 web development using php
45/51
STUDY FORUM
Chapter D
Concu!ion
!he web a&&lication Study Forum is im&lemented as an a&&lication o( 2#
-
8/19/2019 web development using php
46/51
STUDY FORUM
S97PSH$S
Department of Computer Science and Engineering ,UVCE.
Page-#%
-
8/19/2019 web development using php
47/51
STUDY FORUM
Department of Computer Science and Engineering ,UVCE.
Page-#&
-
8/19/2019 web development using php
48/51
STUDY FORUM
Department of Computer Science and Engineering ,UVCE.
Page-#'
-
8/19/2019 web development using php
49/51
STUDY FORUM
Department of Computer Science and Engineering ,UVCE.
Page-#(
-
8/19/2019 web development using php
50/51
STUDY FORUM
)i*liography>$ &ensource 2eb develo&ment using .A00 James .ee, a7a-+ampe+.com:a>a:inde.*tm
Department of Computer Science and Engineering ,UVCE.
Page-$)
http://www.homeandlearn.co.uk/php/php.htmlhttp://onlamp.com/php/index.htmlhttp://onlamp.com/php/index.htmlhttp://www.php-scripts.com/http://www.tizag.com/index.htmlhttp://www.w3schools.com/http://www.pageresource.com/jscript/index4.htmhttp://www.java-samples.com/javascript/index.htmlhttp://www.javascriptkit.com/http://developer.mozilla.org/en/ajax.htmlhttp://onlamp.com/xmlhttprequest.htmlhttp://www.java-samples.com/ajax/index.htmlhttp://www.w3schools.com/http://www.htmlcodetutorial.com/quicklist.htmlhttp://www.java-samples.com/ajax/index.htmlhttp://www.homeandlearn.co.uk/php/php.htmlhttp://onlamp.com/php/index.htmlhttp://www.php-scripts.com/http://www.tizag.com/index.htmlhttp://www.w3schools.com/http://www.pageresource.com/jscript/index4.htmhttp://www.java-samples.com/javascript/index.htmlhttp://www.javascriptkit.com/http://developer.mozilla.org/en/ajax.htmlhttp://onlamp.com/xmlhttprequest.htmlhttp://www.java-samples.com/ajax/index.htmlhttp://www.w3schools.com/http://www.htmlcodetutorial.com/quicklist.htmlhttp://www.java-samples.com/ajax/index.html
-
8/19/2019 web development using php
51/51
STUDY FORUM