Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering

Page created by Stephanie Rowe
 
CONTINUE READING
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Comparison of Web Development Technologies ‐ ASP.NET & PHP
       Master Thesis in Software Engineering

Author:
Ramesh Nagilla (rna10002@student.mdh.se)

Supervisor:
Frank Lüders (frank.luders@mdh.se)

Examiner:
Kristina Lundqvist (kristina.lundqvist@mdh.se)

                                                                   1
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Abstract
Web applications play an important role for many business purpose activities in the modern
world. It has become a platform for the companies to fulfil the needs of their business. In this
situation, Web technologies that are useful in developing these kinds of applications become an
important aspect. Many Web technologies like Hypertext Preprocessor (PHP), Active Server
Pages (ASP.NET), Cold Fusion Markup Language (CFML), Java, Python, and Ruby on Rails are
available in the market. All these technologies are useful to achieve the goals of Clients and
business organizations. ASP.NET and PHP are the most competing out of all the technologies.
Most of the companies and developers think that one is better than other. The main aim of this
thesis is done by taking this point in to the consideration. A Photo Gallery application is
developed using ASP.NET and PHP in order to compare the two Web development technologies.
Many points are taken in to consideration in order to differentiate them and conclude which one
is the better among the two technologies.

                                                                                              2
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Acknowledgements
I would like to thank my supervisor Frank Luders for his constant help, support and guidance
during this thesis work. I also would like to thank my friends who have given me enough
strength and support during this thesis.

                                                                                               3
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Table of Contents
1. Introduction ........................................................................................................................................................ 8
        1.1 Purpose of the document ............................................................................................................... 8
        1.2 Problem Statement ......................................................................................................................... 8
        1.3 Method followed to solve .............................................................................................................. 8
        1.4 Target Audience .............................................................................................................................. 8
        1.5 Web Application.............................................................................................................................. 8
        1.6 Report Outline ................................................................................................................................ 9
2. Background .......................................................................................................................................................10
3. Related Work ....................................................................................................................................................11
4. Fields of Web applications ...........................................................................................................................11
5. Competitive Web technologies...................................................................................................................11
6. Photo Gallery Application functionalities ....................................................................................... 13
     6.1 Registration ................................................................................................................................... 13
        6.2 Log in ............................................................................................................................................. 14
        6.3 Photo Gallery ............................................................................................................................... 15
        6.4 Manage Categories ....................................................................................................................... 16
        6.5 Upload Photos............................................................................................................................... 17
        6.6 Add Comments ............................................................................................................................. 18
7. Database ........................................................................................................................................ 19
8. Implementation in ASP.NET ........................................................................................................... 20
        8.1 ASP.NET ......................................................................................................................................... 20
        8.2 .NET Framework............................................................................................................................ 20
        8.3 SQL Server 2008 ............................................................................................................................ 21
        8.4 ASP.NET development server ....................................................................................................... 22
        8.5 Visual Web Developer 2010 Express ............................................................................................ 22
        8.6 Master Pages................................................................................................................................. 23
        8.7 ASP.NET Content Pages ................................................................................................................ 24
        8.7.1 MasterPage.master.cs .............................................................................................................. 24
        8.7.2 Index.aspx.cs ............................................................................................................................. 24
        8.7.3 login.aspx.cs .............................................................................................................................. 25
        8.7.4 forgotpassword.aspx.cs ............................................................................................................ 25
         8.7.5 changepassword.aspx.cs ........................................................................................................... 25
         8.7.6 myhome.aspx.cs........................................................................................................................ 26
         8.7.7 manage_categories_user.aspx.cs ............................................................................................. 26

                                                                                                                                                                       4
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
8.7.8 photoupload.aspx.cs ................................................................................................................. 26
      8.7.9 photogallery.aspx.cs .................................................................................................................. 27
      8.7.10 feedback.aspx.cs ...................................................................................................................... 27
9. Implementation in PHP .................................................................................................................. 28
      9.1 PHP ................................................................................................................................................ 28
      9.2 WAMP ........................................................................................................................................... 28
      9.3 Apache Server .............................................................................................................................. 29
      9.4 MySQL ........................................................................................................................................... 30
      9.5 DreamWeaver ............................................................................................................................... 32
      9.6 PHP Content Pages........................................................................................................................ 32
       9.6.1 index.php .................................................................................................................................. 32
       9.6.2 login.php ................................................................................................................................... 33
       9.6.3 forgotpassword.php .................................................................................................................. 34
       9.6.4 changepassword.php ................................................................................................................ 34
       9.6.5 photogallery.php ....................................................................................................................... 34
       9.6.6 manage_categories_user.php .................................................................................................. 35
       9.6.7 photoupload.php ...................................................................................................................... 35
       9.6.8 edit_description.php ................................................................................................................. 36
       9.6.9 add_comment.php.................................................................................................................... 36
       9.6.10 feedback.php .......................................................................................................................... 36
10. Comparison between ASP.NET and PHP ....................................................................................... 36
      10.1 Cost ............................................................................................................................................. 40
      10.2 Operating System........................................................................................................................ 41
      10.3 Speed ......................................................................................................................................... 41
      10.4 Language Support ....................................................................................................................... 41
      10.5 Editors ......................................................................................................................................... 41
      10.6 Database compatibility ............................................................................................................... 41
      10.7 Coding ......................................................................................................................................... 42
      10.8 Platform Connectivity ................................................................................................................. 42
      10.10 Support ..................................................................................................................................... 42
      10.11 Tools .......................................................................................................................................... 42
      10.12 Space on the hard disk .............................................................................................................. 42
      10.13 Generating the design code automatically ............................................................................... 43
      10.16 Master Pages ............................................................................................................................ 43
      10.17 Data Controls ............................................................................................................................ 43

                                                                                                                                                               5
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
10.18 Validation Controls ................................................................................................................... 43
       10.19 Security ..................................................................................................................................... 44
11. Conclusion ................................................................................................................................... 43
12. Future Work ................................................................................................................................. 44
13. Bibliography ................................................................................................................................. 45
14. Appendix...................................................................................................................................... 47

                                                                                                                                                            6
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Table of figures
  1.    A typical Web ............................................................................................................................. 09
  2.    Various fields of Web applications..............................................................................................11
  3.    Usage statistics of Web technologies..........................................................................................12
  4.    Registration screenshot .............................................................................................................. 13
  5.    Log in screenshot ........................................................................................................................ 14
  6.    Photo Gallery screenshot ............................................................................................................ 15
  7.    Manage Categories screenshot ................................................................................................... 16
  8.    Upload Photos screenshot .......................................................................................................... 17
  9.    Add Comments ........................................................................................................................... 18
  10.   Diagram for database.................................................................................................................. 19
  11.   ASP.NET Architecture ................................................................................................................ 21
  12.   Visual Studio Working Environment ........................................................................................ 22
  13.   Structure of files in Visual Studio .............................................................................................. 23
  14.   WAMP screenshot...................................................................................................................... 29
  15.   Usage statistics of Web servers..................................................................................................30
  16.   PHPMyAdmin screenshot .......................................................................................................... 31
  17.   Dreamweaver screenshot........................................................................................................... 32
  18.   Default ASP.NET Website ..........................................................................................................37
  19.   Structure of files for default ASP.NET Website ........................................................................ 38

                                                                                                                                                    7
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
1. Introduction

 1.1 Purpose of the Document
This thesis is an effort to fulfil the requirements of Mälardalen University’s Master in Software
Engineering course thesis (CDT 504) in Advanced level. This allowed me to do a project in which I
have to compare two Web technologies. The final part of the course is this report in which I have
written all the experiences and results from this project while analyzing both the Web
technologies.

1.2 Problem Statement
Web technologies play a prominent role in the daily technical needs of almost every Business.
Companies and developers choose many Web Technologies available in the market for
developing their products. Two of the most competing technologies in this field are ASP.NET and
PHP. Many say that the one is better that another in these two according to their own ideas and
views. By this, many are thinking to select the one that is best to implement their product. This
is the problem that I am going to deal with in this thesis.
1.3 Method followed to solve the problem
To achieve the goal, I have created a Web application in both the above specified technologies
that looks similar in all the aspects. By doing this I got my own opinion about these two
technologies. Then I tried to explain a solution to this existing problem in my own way by
considering experience that I got in dealing with both the technologies.
 1.4 Target Audience
Audience for this thesis are particularly those who want to know the most of positives and
negatives from the technologies ASP.NET and PHP. Reading this thesis does not really require
too much of expertise in these fields, although it’s good if they have some prior basic
knowledge.

 1.5 “Web Application” – Definition
A web application is the one that utilizes web and browser technologies to perform one or more
tasks over a network, through a web browser [1]. Simply it is much more than a website. A web
browser in a way uses the Web application to connect the networked tools along with the
systems. These Web applications are stored on the Web servers and tools in it include PHP,
ASP.NET, databases and other. They store all their data on the server and because of this there is
no need for the users to spend extra on hard drives that lead to the installation.

                                                                                                 8
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
Figure 1: A typical Web

 1.6 Report Outline
Report starts in the next chapter two with a background about the technologies and problem
statement in this thesis report. In chapter three, there are topics that will let the readers know
about the use of Web technologies. Chapter four gives competitive description among the
different Web technologies with a pictorial representation.

The chapter five have some important functionalities description of the Web application. The
chapter six is about the database of Web application. Chapter seven consists of the ASP.NET
description and its implementation part. Chapter eight is similar to the previous chapter except
for the change of technology from ASP.NET to PHP.

Chapter nine have many topics that are focused towards the comparison of two technologies.
Chapter ten will let the readers understand the feature differences between two technologies.
Chapter eleven deals with the conclusion, followed by chapter twelve about the future work.
The last two chapters thirteen and fourteen are references and Appendix of the thesis.

                                                                                                     9
Comparison of Web Development Technologies - ASP.NET & PHP - Master Thesis in Software Engineering
2. Background
Web applications play an important role in all kinds of Business platforms. Most of the business
is running mainly because of the web applications. Web applications have become popular as
they are very useful in day‐to‐day developing, maintenance and support activities of many small
and big organizations. Web applications make the things easy and simple. Many things can be
taken care with the help of Web application. Web application has become a part of life for
everybody for completing many of their personal and professional tasks in the modern busy
World.
Numerous technologies are used by different Web development platform companies to develop
various kinds of interesting and useful Web applications. There are so many web applications
that are already in use and some more are in the process of development. Google Apps,
Microsoft Office Live and many are the most famous Web applications.
Some of the famous technologies are PHP, ASP.NET and Java server Pages. These three
technologies are useful for the software developers for creating the dynamically generated web
pages. There are also other technologies like ColdFusion Mark‐up Language, Perl and Python.
ColdFusion is helpful for the development of rich Internet applications with advanced features.
Practical Extraction and Reporting Language (PERL) is a dynamic high level general purpose
programming language. Python is a computer programming language and also a set of software
tools and libraries that was originally developed by Guido Van Rossum [14].
As of now, the most competing technologies from the listed are the Microsoft ASP.NET and
Hypertext Preprocessor PHP. Irrespective of the size, many companies are using these two
technologies and producing very effective and technically advanced products. Business Clients
are also very satisfied with both these technologies usage as they are fulfilling all the
requirements that they need to meet.
The big difference with the two technologies comes into picture when it comes to time,
maintenance, resources, money, security, profit and many other. Small companies mostly prefer
to use PHP as it is an open source that is provided for free. PHP project budget is also
comparatively low than that of Microsoft ASP.NET. Big companies mostly use ASP.NET even
though it is more costly when compared to the PHP. The clients and companies that are using
ASP.NET have their own set of reasons for using this technology. They are ready to buy even
though it not a free source like PHP. These things make much difference and confusion among
clients and new developers.
Business Clients who are new or have different strategy plans of their business need to know
which one to select according to their infrastructure, capital and resources. These are one set of
people that are in confusion on which technology they need to go. The other set of the people
are actually the new developers who want to pursue their career in these domains of Web.
These two have an important purpose to look forward in this thesis and decide on the
technology they want to go ahead according to their professional personalities.

                                                                                                10
3. Related Work
   Previously the students of MDH University compared the two technologies ASP.NET and PHP.
   They built a real estate web application using Active Server Pages (ASP.NET) and Eclipses Helios
   for PHP developers with same functional requirements. Their thesis concludes that they found
   the ASP.NET is more efficient and reliable while PHP is a simple scripting language. The paper
   also tells that the built in tools of ASP.NET helps in the faster development of code when
   compared to PHP (19).

   4. Fields of Web Applications
   Web applications are useful in many areas of business and other needs. Given below is the list
   of categories where in the Web technologies are useful.

                                         Web Applications

Business       Technology       Travel       Health         Government      Shopping           Others

   Figure 2: Various fields of Web applications
   There are many Web technologies available in the market as of now. Every Web technology can
   deliver the same functionalities required for an application in its own style. Considering this
   aspect no Web technology is less in delivering the required functionalities.

   5. Competitive Web Technologies
   Some of the prominent technologies that are mostly used in developing and implementing Web
   applications are ASP.NET, PHP, ColdFusion, Perl, Python, J2EE, Ruby on Rails and many more.
   Please check the given below table for the usage of different Web technologies in the present
   market.

                                                                                                      11
Fig 3: Usage statistics of Web technologies (16)
Statistics are showing that PHP is in the top position as it is used by more than 24692359
Websites. The second position is taken by ASP.NET which is used by more than 19365837
Websites. Rest of the technologies are being used by some other Websites.
By looking at the count of the Website, it is very clear that PHP takes the number one place in
this aspect. The counts of its Websites are numerously more than any other Web technology.
The choice of technology depends upon the personal choice. Many may consider PHP as it is
free to use. But the ASP.NET which is in second position has number of users even though it is
paid. Definitely ASP.NET and PHP are competitive with one another in the market at present as
of now.
I have created a Web application called “Photo Gallery” in both the technologies. I have
implemented the same functionalities in both the technologies for this application. The design
of the Website is similar in both the technologies so that they look familiar in different views.
Please see the application functionalities in the next chapter.

                                                                                                12
6. Functionality of the Photo Gallery Application
   This section describes about the application that is implemented in this thesis. I choose an
   application called “Photo Gallery” for the purpose of achieving goals in this thesis. The
   requirements of the Photo Gallery application are as follows:
 Application must support the user accounts
 Both the authenticated and anonymous users can visit the Website and view every other user
  photo
 All the users must be able to create categories
 The categories have names that are associated with it and useful to organize a user photo
 User should provide the title, category and description of the photo in order to upload it
 Authenticated users can add comments under the photo
 Anonymous users can only view the comments
 User should be able to view a particular photo and can filter them by category
 A feedback page where in everybody can send their comments
   The implementation part is completely done and the descriptions of the functionalities are
   explained below along with the particular Web page screen shots.
   6.1 Registration

                                Figure 4: Registration screenshot
   Registration option is present in the right side of home page in Website. It helps the
   visitors/anonymous users of website to get registered and become the user of Website. There is
   no need to navigate to another page as the registration option is in the first page itself. In order
   to register, you need to fill out the options username, password, email id, security question and

                                                                                                     13
answers. After filling the entire form you just need to click on the button create user. Then the
user will become a registered user. This option is also available in the top right corner of the
Home Page.
6.2 Log in

                     Figure 5: Login screenshot

Log in option is for the authenticated users who are already registered in the Photo Gallery
website. The log in option is located on the top right corner of the home page. Users have to
click on it and then they will be navigated to a separate page. Users are prompted to enter their
email id and password and then click on the log in button down by these two options. Then the
user will be able log in to the Website. There are also the other options in this page. They are
forgot password which is exactly present under the log in button. This one helps the users when
they forgot their password. There is also other option underneath it which is again the
registration option for the anonymous users.

                                                                                                    14
6.3 Photo Gallery

                        Figure 6: Photo Gallery screenshot

Photo Gallery is the main area of focus in this Web application. The left panel of this page has all
the user names with in a table called “Photos of All Users”. This has the list of registered users
with a serial number and the user name. Then the remaining section of the page has all the
photos available with their titles and the option “Add Comment” under every photo. These
photos are the ones that are already uploaded by the users of this Web application. Both the
anonymous and authenticated users can view the photos of all the users in this page. Exactly on
the top right corner of these photos panel, there is a drop down menu of the categories that
states “Select Category” where in an user can select the Category of the Photos he/she want to
see. There is another option next to it called as “View all”. Clicking this one you can see all the
photos that are uploaded by all the users irrespective of the categories that exist in Website.

                                                                                                  15
6.4 Manage Categories

                        Figure 7: Manage Categories screenshot

Manage Categories is another Web page in the photo gallery website. The main intention in
creating this page creation is to let the authenticated users create their own categories. Because
the users have to upload their photos by selecting the category they want to upload the photos
according to the requirements. In order to access this page, user needs to be logged in to their
profile and if they want to add a category, they need to type in the text box which is present in
the page. Then click the add option, now the user can see the category that is added by him/her
in the table that is present down exactly below the text box. The table have all the categories
names along with the serial numbers.

                                                                                                16
6.5 Upload Photos

                             Figure 8: Upload Photos screenshot

This Web page is helpful to the authenticated users to upload their photos. A user needs to be
logged in for accessing this page. If the users want to upload photos, then they need to fill or
give the options that are need to be filled in this page. First of all, they need to select the
category in which they want to upload their photo, after that they have to give the title for that
particular photo. A description should be given in the next option and then users have to browse
their photo from the “choose file” option. After they find their photo file they need to click on
the upload photo. Then their photo is uploaded and it will be displayed in the table below with
the related information. The information table have the details of the photo with its serial
number, Category Name, Title, Description, Date Added and the photo. The left panel of this
page also have another table with the Categories name that already exist in this Website.

                                                                                                17
6.6 Add Comments

                    Figure 9: Add Comments screenshot
Add comments page is used for the purpose of commenting on a particular photo. It comes
active when a user feels to comment on a certain photo. Anonymous users cannot comment on
the photo of the registered users. Only the authenticated users can comment on each photo of
the Website. To comment on a photo, the user need to click on add comment option below the
photo which will navigate to the page which looks similar to the above figure. There is a text box
to write down the comments, users just need to write the comments and then click on submit
button. Then the comments are added for that particular photo.

                                                                                                18
7. Database
   This is the section that has the details of the database that I used in the Web application. There
   are five tables in this database. They are category, comment, feedback, photo details and users.

 tbl_Category – This table is useful in storing the categories that are created by the users and also
  stores the existing categories that are already created by different users.
 tbl_Comment – This table stores the comments that are made by users for the photos in the
  Photo Gallery menu
 tbl_feedback – This table consists of the feedbacks that are sent by the users and visitors of the
  Website.
 tbl_photo_dtls – This table consists of the details of the photo that are uploaded by user. This
  consists of Photo name, description, Category.
 tbl_users – This table consists of the information about the users.

                       Figure 10: Diagram for the database

                                                                                                    19
8. Implementation in ASP.NET
This chapter is entirely focused on the .NET implementation part of Web application. Detailed
explanation about the technologies that are used and the content pages are described in the
next sections of this chapter.
8.1 ASP.NET
ASP.NET is a modern generation Web technology that is used for the development of Web sites.
It was released by Microsoft Corporation. ASP.NET stands for Active Server Pages.NET and also
known as server side programming language. It is a part of .NET framework itself. It consists of
many set of programming classes that are designed to satisfy many kinds of programming needs
[2]. ASP.NET can be called as a Modern generation Web technology from the Microsoft.
Requirements of an ASP.NET project are Web designing language(HTML), Client side scripting
language(JavaScript), Programming language(C#.NET / VB.NET) and the Web Server(IIS /
ASP.NET Development Server).
ASP.NET Website lists that there are millions of applications that are built with ASP.NET. Few
applications that are in the list include Stack overflow, US Airways, The British Museum, Bing,
Xbox 360, MSNBC and many.
8.2 .NET Framework
This is a framework developed by Microsoft and runs primarily on Microsoft Windows. The first
version of the .NET framework was released in February 2002. For this thesis, I have used the
.NET framework 3.5 which was released in November, 2007. .NET framework model provides
the facility to develop and execute the different kinds of applications in an integrated
environment of Visual studio.NET. .NET framework has Common Language Runtime (CLR). This
CLR handles different kinds of services such as language integration, security and memory
management. .NET framework provides a language called Microsoft Intermediate Language
(MSIL) and this is an independent language and platform. Programs are allowed to be developed
in any .NET based language by the MSIL. CLR can recognize the MSIL and it can compile and
execute the codes of MSIL by using the JIT (Just‐In‐Time) compiler that is located in the
client/local machines [5].

                                                                                                  20
VB/C#,C++...

                    Common Language Specification

                                                                                                   Visual Studio.NET
                               ASP.NET Web forms

                                    Data and XML

                                      Base Classes

                        Common Language Runtime

                             Figure 11: ASP.NET Architecture
    8.3 SQL Server 2008
    The SQL Server is a Relational Database Management System that is designed to run on various
    platforms ranging from laptops to different large multi processor servers. In Websites, SQL
    server is used as backend system. SQL Server helps to administrate the database and
    programming tasks with its number of helpful tools. SQL Server is more robust. It is mostly used
    as a Server Database System even though it runs on the desktop systems [10].

    The database name used in this Web application is Photo Album. Language Integrated Query
    (LINQ) is used in order to access the data from the database. There is another folder called
    App_Code in the solution explorer where the data classes are created.

    Steps for creating a database connection in SQL server are as follows:

   Launch the Visual Studio Web Developer Express
   Right click the database connection in the solution explorer
   Select the option “create a new SQL server database”
   Provide the server credentials
   Provide the server name and click ok

                                                                                                           21
8.4 ASP.NET development server
   ASP.NET development server is developed by Microsoft. It is in‐built in visual studio and
   supports only ASP.NET Websites. It was introduced along with the Visual studio 2005. It can be
   called as personal web server. It uses different ports for different web sites. The port number
   will be generated at the run time. It is built to run the ASP.NET Web pages under the local host
   [15].
   8.5 Visual Web Developer 2010 express
   This is a free Visual Studio Web applications development environment for building and testing
   the next generation standard‐based Web services and applications [3]. Visual studio is an
   integrated development environment produced by Microsoft for .NET software. .NET framework
   in it supports many programming languages by allowing interoperability [18].

              Figure 12: Visual Studio working environment
   The advantages of Visual Web Developer Express are as follows:
 An editor that helps the developer to work with CSS, HTML in all the view(Source, Design and
  Split)
 Debugging support for JavaScript, ASP.NET and C#.
 Strong built in support for FTP‐based web deployment and database deployment.
 IntelliSense feature for syntax highlighting and also the auto‐compilation that will help in
  improving the productivity.
 Helps in creating and deploying the quality Web applications quickly and easily.
 Have a rich design surface

                                                                                                      22
 Have an ability to test the developed web applications immediately with the integrated Web
  server [3]. It is a freeware development environment including the components frameworks,
  Web server and database

        Figure 13: Structure of files in Visual Studio
        8.6 Master Pages
        Consistent design in a Website helps the visitors feel comfortable around the Website. By using
        a master page, the development team can give the users a global way approach to the each and
        every Web page [4].
        Steps to create a master page are as follows:
   I.   Select the solution explorer in Visual Studio, Right click it
  II.   Click the add new item
 III.   Select Visual C# from the Installed templates that are on the left side
 IV.    Select the Master Page from the list beside it
  V.    Name the Master page at the down
 VI.    Click add, then the master page is created
        Master pages behave like the normal pages with in the Visual Studio Web developer express. We
        can add the Html and server controls to it and can manage both in the mark‐up and design view.
        The master page is not a true page itself. It only serves as a template for the other pages in the
        Site [4].

                                                                                                       23
8.7ASP.NET Content Pages
8.7.1 MasterPage.master.cs
This page is concentrated on the user log in and log out functionalities. Sessions are maintained
after the users are logged in. When the users logged out, the sessions are abandoned and the
pages will be redirected to the home page.
protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["userId"] == null)
        {
            Response.Redirect("Login.aspx");
        }

          else
          {
              if (Session["username"] != null)
              {
                  lblwecome.Text = " Welcome " + Session["username"].ToString()
+ " ";
               }

8.7.2 Index.aspx.cs
This page has the information about the Website and the registration option for the anonymous
users where the new users have to enter the details of name, email, password and security
credentials. It also has the log in option for the authenticated users which will lead them to the
manage categories and profile pages.
    if (dt.Rows.Count == 0)
        {
            string insert = "insert into tbl_users (name, email, password,
confirmpassword, securityquestion, securityanswer, createddate,status) values
('" + globalFunctions.checkText(txtusername.Text) + "','"
+globalFunctions.checkText( txtemail.Text) + "','" + txtpwd.Text + "','" +
txtconfimpwd.Text + "','" + txtsecurityqust.Text + "','" +
txtsecurityansw.Text + "','" + DateTime.Now.ToString() + "',0)";

            dbFunctions.processQuery(insert);
            Session["name"] = txtusername.Text;
            string strGetUid = "Select user_id from tbl_users where email='" +
txtemail.Text + "' and name='" + txtusername.Text + "'";
         string strUId= dbFunctions.getSinglevalue(strGetUid);
}

                                                                                                24
8.7.3 Login.aspx.cs
This page prompts the user to log in with the user email and the password. A user can
successfully log in after this. If the password is not the correct, then the users can see a message
“invalid password”.
if (dt.Rows.Count != 0)
        {
            if (txtpwd.Text == dt.Rows[0]["password"].ToString())
            {
                Session["userId"] = dt.Rows[0]["user_id"];
                Session["username"] = dt.Rows[0]["name"].ToString();
                Response.Redirect("manage_categories_user.aspx");
            }
            else
            {
                globalFunctions.msg("invalid password", this);

               }

8.7.4 Forgotpassword.aspx.cs
This page helps as an option to the user when he/ she forget their password. Users have to
enter few details in forgot password page, and then the password will be sent to their e‐mail id.
8.7.5 Changepassword.aspx.cs
This page is responsible in changing the password for an account. The user is prompted to enter
the details in this page like email id, current password, new password and then the password
will be changed.
protected void btnchgpawd_Click(object sender, EventArgs e)
    {
        string str = "select * from tbl_users where password='" +
globalFunctions.checkText(txtcurrpass.Text) + "' and email='" +
(txtemail.Text) + "'";
           DataTable dt=dbFunctions.getTable(str);
        if(dt.Rows.Count >0)
        {
            string strupdate = "update tbl_users set password='" +
globalFunctions.checkText(txtnewpass.Text) + "',confirmpassword='" +
txtnewconfim.Text + "' where email='" + txtemail.Text + "'";
            dbFunctions.processQuery(strupdate);
            globalFunctions.msg ("Your password modified successfully “,
this);
             Response.Redirect ("login.aspx");
        }

                                                                                                  25
8.7.6 Myhome.aspx.cs
This page is the home for the users who logged in. This comprises of the options change
password and profile deletion. The users can click on whatever option they want to use, then
this page will navigate to the respective page.
8.7.7 Manage_categories_user.aspx
This page helps the user to add their categories to the photo gallery. This is possible only when
the user is logged in. The users can type in the name they want and click on add. Then the
category name is added to the tbl_category and users can see it in the same page.
protected void Page_Load(object sender, EventArgs e)
    {

          if (!IsPostBack)
          {
              filldata();
          }

             }
     protected void btnadd_Click(object sender, EventArgs e)
     {

                string insert = "insert into tbl_category (category_name,
user_id) values ('" +globalFunctions.checkText( txtcat.Text) + "'," +
Session["userId"] + ")";
                dbFunctions.processQuery(insert);
                globalFunctions.msg(" password you are successfully added
category name", this);

                   filldata();
                   clear();
                  }

 8.7.8 Photoupload.aspx.cs
This page helps the users to add their photos. For uploading the photos, users have to follow
certain steps and fill in some details. Users have to browse the file path and set it. Then the
users have to fill in the details like photo name, description, and category. Then click on add
which will upload the photo to the Website. Everybody can see these uploaded photos in the
Website along with the details that are given by user when it was uploaded.
          if (imageupload.HasFile)
          {

            string strFilePath = Path.GetExtension(imageupload.FileName);
            if (strFilePath == ".jpg" || strFilePath == ".jpeg" ||
strFilePath==".png" )
            {
            string fname = System.IO.Path.GetFileName(imageupload.FileName);
            thumbimage = fname;
            string filepath = MapPath("Gallery/" + thumbimage);
            imageupload.SaveAs(filepath);

                                                                                                  26
string insert = "insert into
tbl_photo_dtls(user_id,user_name,category_id,category_name,photo_title,photo_d
escription,photo_path,uploadeddate)values(" + Session["userId"] + ",'" +
Session["username"] + "'," + ddlcatname.SelectedValue + ",'" +
ddlcatname.SelectedItem + "','" + globalFunctions.checkText(txttitle.Text) +
"','" + globalFunctions.checkText(txtdesc.Text) + "','" + thumbimage + "','" +
DateTime.Now.ToString() + "')";
                dbFunctions.processQuery(insert);
                string query = "select * from tbl_photo_dtls where User_id='"
+ Session["userId"] + "' and category_id='" + ddlcatname.SelectedValue + "'
order by photo_id desc";
                DataTable dt = dbFunctions.getTable(query);
                if (dt.Rows.Count > 0)
                {
                    grdcatefull.DataSource = dt;
                    grdcatefull.DataBind();
                }
               clear();
            }

8.7.9 Photogallery.aspx.cs
This page is useful for everyone even though they are not registered. This page will let every
visitor and user to check out all the photos that are uploaded in the Website until that time.
8.7.10 Feedback.aspx.cs
This page is useful to send a feedback or comment about the Website. Whomsoever want to
submit the feedback, they just need to fill in few details like name, email and message and then
click on the submit button. The successfully sent message will appear to the user who sent the
feedback at the same instance immediately after click the submit button.
protected void btnsubmit_Click(object sender, EventArgs e)
    {
        string fed = "insert into tbl_feedback(name,email,message)values('" +
globalFunctions.checkText(txtname.Text) + "','" +
globalFunctions.checkText(txtmailinfo.Text) + "','" + txtcomment.Text + "')";
        dbFunctions.processQuery(fed);
        globalFunctions.msg(" Your feedback has been sent successfully ",
this);
        clear();

                                                                                                 27
9. Implementation in PHP
9.1 PHP
PHP is a scripting language originated early in 1995 by a software development contractor
named Rasmus Lerdorf. It developed as one of the best larger scripting languages around the
globe. [6].

PHP is an open‐source scripting language for creating the dynamic Web content. PHP is one of
the fastest scripting languages around the globe. PHP is easy to use. Many scripts take long time
to compile and execute but it is nullified with the use of PHP code caches. PHP is possible to use
Integrated Development Environments (IDE’s).

In PHP 4.0 they improved resource handling, given object oriented support, native session
handling, COM/DCOM support, native java support, Perl compatible regular expression (PCRE)
library. Like this we can see several other versions improving a lot supportive initiatives [7].

Most of the Website is using PHP. Some of the prominent Websites that are using PHP are Face
book, Oracle and Yahoo.

9.2 WAMP
WAMP server is a web development platform on windows allowing you to create dynamic web
applications with Apache and MySQL [8].

                                                                                                   28
Figure 14: WAMP screen shot
It helps the developers to create Web applications by providing the in‐built Apache, PHP and
MySQL database. PhpMyAdmin allows managing the database easily. WAMP have all these
features inbuilt in it which will help the developers to make the development faster.
9.3 Apache Server
Apache HTTP server was released in 1995. It is a powerful and flexible Web server. It is actively
being developed. It is developed and maintained by Apace Software Foundation. Apache server
is used in PHP implementation. It has the features to run virtually on all the computer platforms.
In the beginning it used to run primarily on a UNIX based web server. But now, Apache runs on
all the flavours of UNIX and also on Windows platform [11]. In this project, I did not installed
Apache Server separately as it comes in default with the WAMP.
Apache users have a lot of support from its Website. The usage of Apache is more when it comes
to usage when compare with the other servers. The given below figure shows a pictorial
representation of servers usage.

                                                                                                29
Fig 15: Usage statistics of Web Servers [17]
Above figure shows the comparison between the Apache server and the other type of servers.
Apache server is the number one server that is used by many companies. Its usage percentage is
65.6 which is more than a half of the total percent. The main reason would be that it is easy and
flexible to use. Next most used server is IIS with a percentage of 18. Rest of the servers share the
remaining percentage of usage.
9.4 MySQL
MySQL is an open source software that is possible for anyone to use. Everybody can download
the MySQL software from Internet for free. SQL stands for Structured Query Language which is
a standardised language used to access the databases. This is a relational database that stores
data in separate tables which adds flexibility [20]. This is a very robust and fast relational
database management system. MYSQL server controls the access to project data and makes
sure that multiple users can work with it parallel with fast access. It also ensures that only the
authorised user can have the access privileges [21].
Many of Multi National Companies (MNC’s) and fast growing organizations use MySQL to save
money, time keeping their high volume, critical business systems, and packaged software
including industry leaders like Yahoo, Google, Twitter and Wikipedia [9].
MySQL is easy to use and have a high performance along with the reliability. MySQL can run on
20 different platforms. Time and memory can be saved by using the MySQL.
Given below is the code that is used for connecting MySQL database in the project:

                                                                                                 30
if(HOST_NAME!=LOCAL_HOST_NAME){

define ("DB_SERVER", "");

define ("DB_USER", "");

define ("DB_PASSWORD", "");

define ("DB_NAME", "");

}

else{

define ("DB_SERVER", "localhost");

//      define ("DB_USER", "photoalbum");

define ("DB_USER", "root");

//      define ("DB_PASSWORD", "photoalbum");

define ("DB_PASSWORD", "");

define ("DB_NAME", "photoalbum");

}

                   Figure 16: PHPMyAdmin screenshot

                                                      31
9.5 Dreamweaver
Dreamweaver is a tool that is created by Adobe for creating the dynamic websites. It is a
development and management program for the Websites [12].

                   Figure 17: Dreamweaver screenshot

9.6 PHP Content Pages
This section consists of the PHP pages in the Photo gallery application. The screenshots are not
provided for these pages as they are identical with the above given ASP.NET pages.
9.6.1Index.php
This page is the home page of the application in PHP. It displays the welcome information along
with the menu. There is panel in the right side of this page for the visitors to register in the
Website. Users have to fill in the data like name, email, password along with the security
question and answers. Then by clicking on the create user they are registered in the Website.
if(isset($_POST['CreateUser'])) {

                       $created_date=date("Y-m-d H:i:s");

                                                                                               32
$sql = "INSERT INTO
tbl_users(name,email,password,confirmpassword,securityquestion,securityanswer,
createddate)
VALUES('".$_POST["username"]."','".$_POST["email"]."','".$_POST["password"]."'
,'".$_POST["confirmpassword"]."','".$_POST["securityquestion"]."','".$_POST["s
ecurityanswer"]."','$created_date')";

        //echo $sql;

        //$resqry=mysql_query($sql) or die(mysql_error());

        if(mysql_query($sql)){

               $msg="You have Successfully Registered with photoalbum.com";

               //$this->MemberId = mysql_insert_id();

               //$this->MemberLogin("register");

        }

9.6.2 Login.php
This page handles the log in functionality for the registered users. This page prompts the users
to enter the username and password in order to log in. After logging in, this page will be
redirected to the profile page with the user options in the Website.
if(isset($_POST['login'])){

               $emailid=$_POST['emailid'];

        $pwd=$_POST['password'];

        //$_SESSION['email']=$emailid;

               $sql = "SELECT name,user_id,email

                       FROM tbl_users WHERE email='$emailid' AND password='$pwd'";

        $rs = mysql_query($sql) or die(mysql_error());

                       if(mysql_num_rows($rs) > 0){

               $res=mysql_fetch_assoc($rs);

               $dbname=$res['name'];

               $_SESSION['uid']=$res['user_id'];

             $_SESSION['email']=$res['email'];

               $_SESSION['username']=$res['name'];

                                                                                                   33
//print_r($_SESSION);

                //die;

                header('location:myhome.php');

        }

9.6.3 Forgotpassword.php
This page comes in handy when the user forgot their password. This Page helps the users to
retrieve the password when they have forgotten.
if(isset($_POST['forgotpassword'])){

        include_once INCLUDE_PATH."mailers/welcomemailer.php";

        $sql = "SELECT user_id, email, name, password

                        FROM ".USER_TABLE."

                        ";

        $sql .= " WHERE email='".$_POST["email"]."'";

        $rs = mysql_query($sql) or die(mysql_error());

        if(mysql_num_rows($rs) > 0){

                $arrData = mysql_fetch_assoc($rs);

        }

9.6.4 Changepassword.php
This page helps the user to change the password by entering the required information in that
page.
9.6.5 Photogallery.php
This page displays the photos of all users in the website. This is not only restricted to the users
for viewing it. Any visitor can view the photo gallery in the Website.
if(isset($_POST['search'])){

        $category=$_POST['category'];

 $selqry="select photo_path from".PHOTO_TABLE."where category_id
='$category'";

$exec=mysql_query($selqry) or die(mysql_error());

$res=mysql_fetch_assoc($exec);

                                                                                                      34
}

9.6.6 Manage_categories_user.php
This will help the users to manage their categories. They can add the categories and also can
select any category available in the Website in order to upload their photos.
if(isset($_POST['category'])){

        $category=$_POST['category'];

        $userid=$_SESSION['uid'];

       $checkcatqry="select category_id from tbl_category where
category_name='$category' ";

$checkexe=mysql_query($checkcatqry) or die(mysql_error());

        $num=mysql_num_rows($checkexe);

        if($num==0){

        $catinsert="insert into tbl_category(category_name ,user_id)
values('$category','$userid')";

        $qryexec=mysql_query($catinsert) or die(mysql_error());

        }

        if($qryexec){

                $msg="Category has been Added";

        }else{

                $msg="Category already exists";

        }

}

9.6.7 Photoupload.php
This page helps the user to upload their photos. User should provide few details that are in this
page in order to upload the photo.
if(isset($_POST['upload'])){

if(move_uploaded_file($_FILES['photo']['tmp_name'],"uploads/".$_FILES['photo']
['name'])){

                                $msg="upload complete";

                                                                                                35
}

9.6.8 Edit_description.php
This page helps the user to edit the description in the photo upload page
9.6.9 Add_comment.php
A registered user can comment on any photo with the use of this add comment page.
if(isset($_POST['Add'])){

        $photoid=$_GET['photoid'];

        $comment=$_POST['comment'];

       $addcomment="insert into tbl_comment(comment_text,user_id,photo_id)
values('$comment','$uid','$photoid')";

        $qryexec=mysql_query($addcomment) or die(mysql_error());

        if($qryexec){

                $msg="Comment added Successfully";

                       }

}

9.6.10 Feedback.php
This page is for the purpose of sending the feedback. All the visitors and users can send the
feedback using this form.

10. Comparison between ASP.NET and PHP from a developer’s
perspective
Choosing the best technology among these two is a challenging task for many. I have tried to
select the one from these two from my experience and many other factors. The method of
choosing one of them may depend upon different reasons. Some may think of the things like
cost, platform and other may think of features and security.
Many may select ASP.NET because of its good features and the comfortable platform features.
Mostly small companies or for small projects many may consider PHP because of its easily
adoptable nature. If we see in technical, they both perform the same thing with different
approaches and the personalities. We can follow the one whichever is the most similar to the
style of our own.

                                                                                                36
You can also read