SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
INSTALLING, CONFIGURING, AND DEVELOPING WITH XAMPP
by Dalibor D. Dvorski, March 2007

Skills Canada – Ontario


    DISCLAIMER: A lot of care has been taken in the accuracy of information provided in this article,
    however, it cannot be guaranteed that inaccuracies will not occur. The author and Skills Canada will not
    be held responsible for any claims or damages caused as a result of any information from this article.

This article explains the installation and configuration process of the XAMPP Apache distribution, and
then provides a step-by-step tutorial on developing a simple address book program using the PHP
programming language and MySQL database package.

In order to comply with the Ontario Skills Competition, this article will use the following coding
standards and tools: XHTML 1.0 Transitional, PHP 5.0, MySQL 5.0, and phpMyAdmin 2.9.


About XAMPP and Installation Requirements

XAMPP is a small and light Apache distribution containing the most common web development
technologies in a single package. Its contents, small size, and portability make it the ideal tool for
students developing and testing applications in PHP and MySQL. XAMPP is available as a free
download in two specific packages: full and lite. While the full package download provides a wide
array of development tools, this article will focus on using XAMPP Lite which contains the necessary
technologies that meet the Ontario Skills Competition standards. As the name implies, the light version
is a small package containing Apache HTTP Server, PHP, MySQL, phpMyAdmin, Openssl, and
SQLite. For more details on the packaging and versions, refer to TABLE 1.

In order to be able to successfully run XAMPP Lite, you will require 17 MB for the self-extracting ZIP
installation archive and at least 118 MB after it has been extracted on a local hard disk or USB drive.




                                TABLE 1: XAMPP and XAMPP Lite feature
                                comparison chart.


1
Obtaining and Installing XAMPP

As previously mentioned, XAMPP is a free package available for download and use for various web
development tasks. All XAMPP packages and add-ons are distributed through the Apache Friends
website at the address: http://www.apachefriends.org/. Once on the website, navigate and find the
Windows version of XAMPP Lite and download the self-extracting ZIP archive. After downloading
the archive, run and extract its contents into the root path of a hard disk or USB drive. For example,
the extract path for a local Windows installation would simply be C:.

If extracted properly you will notice a new xampplite directory in the root of your installation disk. In
order to test that everything has been installed correctly, first start the Apache HTTP Server by
navigating to the xampplite directory and run the apache_start.bat batch file.

    NOTE: Depending on your local Windows configuration, you may be asked to provide network access to
    the Apache HTTP Server. It is important that you allow network access to the server through your
    firewall in order to have a functioning server.

Next we will test if the server is running correctly by opening an internet browser and typing
http://localhost/ into the address bar. If configured correctly, you will be presented with a screen
similar to that of the one in FIGURE 1.




           FIGURE 1: XAMPP splash screen.

In order to stop all Apache processes do not close the running terminal application, but instead run
another batch file in the xampplite directory called apache_stop.bat.


2
PHP Hello World

In the previous pages we installed and ran the Apache HTTP Server with success. The next step is to
write a simple “Hello World” program in PHP that will test the configuration of PHP under XAMPP.

In a text editor, such as TextPad, write the following lines of code:




The above code example starts a new XHTML document with the page title set as “Hello World” and
then prints a single line of text, Hello World, using the echo PHP language construct.

In order to run and test this PHP program, save it into your xampplitehtdocs directory with the file
name of helloWorld.php. Then, to view it in your browser, simply type in
http://localhost/helloWorld.php into the address bar. If done correctly, you will see your Hello
World line of text in the web browser as shown in FIGURE 2.




          FIGURE 2: Resulting output for helloWorld.php.


3
Creating a Database and Table, and Inserting Data

Now that we have run and tested Apache and PHP, the next step is running MySQL and creating a
database and table which will hold information for our address book program. In order to start
MySQL, navigate to the xampplite directory and run the mysql_start.bat batch file.

    NOTE: Similarly to the Apache HTTP Server, MySQL will also need network access; therefore in order
    to have a functioning database it is important to allow this access through your local Windows firewall
    configuration.

The XAMPP Lite package contains an application called phpMyAdmin which allows developers to
administer and maintain MySQL databases. For the remainder of this article we will be using
phpMyAdmin to create a database and table, and enter test data used in the address book program. In
order to start phpMyAdmin, you must first copy the phpMyAdmin folder from the xampplite directory
and place it into the xampplitehtdocs directory. Before testing phpMyAdmin, make sure that both
Apache and MySQL are running by opening their respective batch files: apache_start.bat and
mysql_start.bat. Along with Apache and MySQL running in the background, type
http://localhost/phpMyAdmin/ into your internet browser. If successful you will be presented with a
phpMyAdmin start page similar to the one in FIGURE 3.




            FIGURE 3: phpMyAdmin start page.


4
The first step with phpMyAdmin running is creating a new database. To do this, point to the textbox
labelled Create new database and type addressBook as the name of a new database. Upon doing so,
you will be forwarded to a screen similar to the one in FIGURE 4. Next, insert a new table in the
addressBook database by typing colleague into the table name textbox and clicking the Go button to
proceed with creating the table.




            FIGURE 4: Creating a new table in the addressBook database.

Following the creation of the colleague table, you will be required to insert the columns that make up
your table. By using TABLE 2 as a reference, insert the necessary columns that will make up your
colleague table for the address book.




TABLE 2: Table summary for the colleague table.

Lastly, with the database and table created, we next need to input some data into the table. Using the
fictional information from TABLE 3 on the next page, input the contact data into your own table.

    NOTE: When inputting data into the table, leave the id field blank because it is set to auto increment to an
    automatic number on every record entry.




5
TABLE 3: Fictional table data for the colleague table.

We are now ready to write the PHP program that will connect to the database and display our data in an
internet browser. The procedure that we will write this program is to first establish a connection with
the database using PHP, then start our XHTML deceleration and meta data, and finally in the body of
our page, write a loop that will iterate through each record in the colleague table and display that data
in the browser.




The PHP block above will connect to our database using localhost as the address, root as the
username, and a blank password field. This configuration of root as the username and a blank
password is the default that is set when phpMyAdmin is configured and is what we will be using for
our examples.

    NOTE: Although it is perfectly fine to use the default username and password for learning purposes, it is
    strongly suggested to change the password to something more secure if developing full web applications.

Following the mysql_connect("localhost", "root", ""); line of code is another line stating that we
will be connecting to and using the addressBook database. Lastly, we will create a variable called
result which will contain a SQL query that will select all records from the colleague table.




6
In the above code example you will notice that the PHP code block, contained within <?php and ?>, is
started and then ended before declaring the XHTML document. Remember that in the “Hello World”
example earlier in this article we also had a PHP code block within a XHTML paragraph tag. This is
important to note because XHTML and PHP can interchangeably be used within one another. This
concept will also be shown when we write a PHP loop to retrieve all the records from the database and
display it in a XHTML table.

Insert a couple new lines after the closing </head> tag and then type in the following code:




This new addition to your code will simply start the body of your document and then place a new
XHTML table, along with a new table row followed by five table headings: ID, First Name, Last
Name, Telephone, and Email Address.




7
Next we will create a new PHP code block in which we write a while loop that goes through each
database table record and outputs each piece of data in a new XHTML table cell:




This loop will write a new table row for each record by printing the <tr> tag and then also write the id,
firstName, lastName, telephone, and email into its own respective table cells using the <td> tags.


Finally, before ending the loop, the table row is closed by printing out </tr>. The PHP code block is
concluded by freeing the memory with mysql_free_result($result); and closing the database
connection with mysql_close();.

The majority of the code has now been written, however, to properly end this XHTML document we
will need to insert a few more closing tags:




You may refer to the next page for complete code of the address book program.




8
9
Now that you have created a database and table, inserted some data into that table, and written a
program that reads the data using PHP, all that is left to do is test, and if required debug.

Making sure that the Apache HTTP Server, along with MySQL are running, open up an instance of
your internet browser and type in the location of your address book PHP file. For example, if you
created an addressBook folder inside the htdocs folder, then the path to run the address book program
would be: http://localhost/addressBook/index.php. If done correctly, you will be presented with a
page similar to that of the one in FIGURE 5. This figure shows the address book program running with a
XHTML table showing the data from the colleague table. If you encounter an error, please review
and compare your code with the complete code provided on the previous page. Lastly, to stop and
close all processes run the apache_stop.bat and mysql_stop.bat batch files for the server and database
respectively.




            FIGURE 5: The address book program displaying contact information from the database.



Conclusion

Throughout this article you have been shown the beginning concepts that will allow you to set up a
development environment, create and administer a database, and write a program that connects to a
database and retrieves data.

Although these concepts are important ones, they are in no means the end of an application. By using
the address book program as an example, there is still a lot of features that can be implemented in such
an application. Features such as editing contact information, deleting contacts, adding new contacts,
and being able to email contacts through a form are all additions that can be implemented to the
example used in this article. Challenge yourself, use this article and other resources as a jump-start and
try adding other capabilities to your own address book program!

10

Contenu connexe

Tendances

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhostIIUM
 
A Complete Installation Guide for Orangescrum
A Complete Installation Guide for OrangescrumA Complete Installation Guide for Orangescrum
A Complete Installation Guide for OrangescrumOrangescrum
 
Apache ppt
Apache pptApache ppt
Apache pptReka
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerRajiv Bhatia
 
Developing web applications
Developing web applicationsDeveloping web applications
Developing web applicationssalissal
 
Ibm tivoli access manager for e business junctions and links redp4621
Ibm tivoli access manager for e business junctions and links redp4621Ibm tivoli access manager for e business junctions and links redp4621
Ibm tivoli access manager for e business junctions and links redp4621Banking at Ho Chi Minh city
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xamppJin Castor
 
mule salesforce
mule salesforcemule salesforce
mule salesforceF K
 
A linux mac os x command line interface
A linux mac os x command line interfaceA linux mac os x command line interface
A linux mac os x command line interfaceDavid Walker
 
Aj
AjAj
AjReka
 
Mule with salesforce push topic notification copy
Mule with salesforce push topic notification   copyMule with salesforce push topic notification   copy
Mule with salesforce push topic notification copySanjeet Pandey
 

Tendances (19)

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
 
A Complete Installation Guide for Orangescrum
A Complete Installation Guide for OrangescrumA Complete Installation Guide for Orangescrum
A Complete Installation Guide for Orangescrum
 
Babitha.4appach
Babitha.4appachBabitha.4appach
Babitha.4appach
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
Lamp
LampLamp
Lamp
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
 
Asp.Net Database
Asp.Net DatabaseAsp.Net Database
Asp.Net Database
 
Asp.Net Tutorials
Asp.Net TutorialsAsp.Net Tutorials
Asp.Net Tutorials
 
Unit 2.1 Part 4
Unit 2.1 Part 4Unit 2.1 Part 4
Unit 2.1 Part 4
 
Developing web applications
Developing web applicationsDeveloping web applications
Developing web applications
 
Ibm tivoli access manager for e business junctions and links redp4621
Ibm tivoli access manager for e business junctions and links redp4621Ibm tivoli access manager for e business junctions and links redp4621
Ibm tivoli access manager for e business junctions and links redp4621
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xampp
 
Cracking CTFs - Sysbypass CTF Walkthrough
Cracking CTFs - Sysbypass CTF WalkthroughCracking CTFs - Sysbypass CTF Walkthrough
Cracking CTFs - Sysbypass CTF Walkthrough
 
Apache
ApacheApache
Apache
 
mule salesforce
mule salesforcemule salesforce
mule salesforce
 
A linux mac os x command line interface
A linux mac os x command line interfaceA linux mac os x command line interface
A linux mac os x command line interface
 
Aj
AjAj
Aj
 
Mule with salesforce push topic notification copy
Mule with salesforce push topic notification   copyMule with salesforce push topic notification   copy
Mule with salesforce push topic notification copy
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 

En vedette

PPD SMK Kristen Purwodadi 2014 2015
PPD SMK Kristen Purwodadi 2014 2015PPD SMK Kristen Purwodadi 2014 2015
PPD SMK Kristen Purwodadi 2014 2015Apoloos Ryan Wibowo
 
Fungsi dari f1 sampai f12 pada keyboard
Fungsi dari f1 sampai f12 pada keyboardFungsi dari f1 sampai f12 pada keyboard
Fungsi dari f1 sampai f12 pada keyboardApoloos Ryan Wibowo
 
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...AFS Gender in Aquaculture and Fisheries
 
NFV Ecosystem Enabler - a well-enabled VNF package catalyst
NFV Ecosystem Enabler - a well-enabled VNF package catalystNFV Ecosystem Enabler - a well-enabled VNF package catalyst
NFV Ecosystem Enabler - a well-enabled VNF package catalystJenny Huang
 
Domestic violence
Domestic violenceDomestic violence
Domestic violenceAmlan Patel
 
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)AFS Gender in Aquaculture and Fisheries
 

En vedette (18)

TECHNO1
TECHNO1TECHNO1
TECHNO1
 
Presentation1
Presentation1Presentation1
Presentation1
 
PPD SMK Kristen Purwodadi 2014 2015
PPD SMK Kristen Purwodadi 2014 2015PPD SMK Kristen Purwodadi 2014 2015
PPD SMK Kristen Purwodadi 2014 2015
 
Burundanga
BurundangaBurundanga
Burundanga
 
Kepemimpinan
KepemimpinanKepemimpinan
Kepemimpinan
 
2012 06-22 ngf mekong afs and naca
2012 06-22 ngf mekong afs and naca2012 06-22 ngf mekong afs and naca
2012 06-22 ngf mekong afs and naca
 
Fungsi dari f1 sampai f12 pada keyboard
Fungsi dari f1 sampai f12 pada keyboardFungsi dari f1 sampai f12 pada keyboard
Fungsi dari f1 sampai f12 pada keyboard
 
Hàbits dels infants
Hàbits dels infantsHàbits dels infants
Hàbits dels infants
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...
Fish, Food Security and Nutrition: presented at 10th Indian Fisheries and Aqu...
 
Mempertahankan pelanggan
Mempertahankan pelangganMempertahankan pelanggan
Mempertahankan pelanggan
 
NFV Ecosystem Enabler - a well-enabled VNF package catalyst
NFV Ecosystem Enabler - a well-enabled VNF package catalystNFV Ecosystem Enabler - a well-enabled VNF package catalyst
NFV Ecosystem Enabler - a well-enabled VNF package catalyst
 
Domestic violence
Domestic violenceDomestic violence
Domestic violence
 
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)
Need, Greed and Speed: What History Tells Us about Fisheries (and Aquaculture)
 
Does women’s empowerment have economic benefits?
Does women’s empowerment have economic benefits?Does women’s empowerment have economic benefits?
Does women’s empowerment have economic benefits?
 
Bse vs nse
Bse vs nseBse vs nse
Bse vs nse
 
Rsa Crptosystem
Rsa CrptosystemRsa Crptosystem
Rsa Crptosystem
 
Looking through a Gender Lens at Social Responsibility in Aquaculture
Looking through a Gender Lens at Social Responsibility in AquacultureLooking through a Gender Lens at Social Responsibility in Aquaculture
Looking through a Gender Lens at Social Responsibility in Aquaculture
 

Similaire à Installing configuringdevelopingwithxampp

How to configure PHP with IIS or Apache on Windows
How to configure PHP with IIS or Apache on WindowsHow to configure PHP with IIS or Apache on Windows
How to configure PHP with IIS or Apache on WindowsRizban Ahmad
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Boxguest34a3a419
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows BoxJayanta Dash
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationChetan Soni
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPHP Barcelona Conference
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpaimaq9a
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLkangaro10a
 
Prabu apache installations
Prabu apache installationsPrabu apache installations
Prabu apache installationsPrabu Cse
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011Alfred Ayache
 
2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slidesMasterCode.vn
 

Similaire à Installing configuringdevelopingwithxampp (20)

How to configure PHP with IIS or Apache on Windows
How to configure PHP with IIS or Apache on WindowsHow to configure PHP with IIS or Apache on Windows
How to configure PHP with IIS or Apache on Windows
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
Mantis Installation for Windows Box
Mantis Installation for Windows BoxMantis Installation for Windows Box
Mantis Installation for Windows Box
 
SubjectsPlus Manual in Compatible with XAMPP
SubjectsPlus Manual in Compatible with XAMPPSubjectsPlus Manual in Compatible with XAMPP
SubjectsPlus Manual in Compatible with XAMPP
 
Wamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and ConfigurationWamp & LAMP - Installation and Configuration
Wamp & LAMP - Installation and Configuration
 
Lampstack (1)
Lampstack (1)Lampstack (1)
Lampstack (1)
 
Php Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi MensahPhp Applications with Oracle by Kuassi Mensah
Php Applications with Oracle by Kuassi Mensah
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
PHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for phpPHP tutorials , php tutorials for beginners , tutorials for php
PHP tutorials , php tutorials for beginners , tutorials for php
 
Its3 Drupal
Its3 DrupalIts3 Drupal
Its3 Drupal
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
 
Prabu apache installations
Prabu apache installationsPrabu apache installations
Prabu apache installations
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011WP Sandbox Presentation WordCamp Toronto 2011
WP Sandbox Presentation WordCamp Toronto 2011
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides2 introduction-php-mvc-cakephp-m2-installation-slides
2 introduction-php-mvc-cakephp-m2-installation-slides
 

Dernier

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Installing configuringdevelopingwithxampp

  • 1. INSTALLING, CONFIGURING, AND DEVELOPING WITH XAMPP by Dalibor D. Dvorski, March 2007 Skills Canada – Ontario DISCLAIMER: A lot of care has been taken in the accuracy of information provided in this article, however, it cannot be guaranteed that inaccuracies will not occur. The author and Skills Canada will not be held responsible for any claims or damages caused as a result of any information from this article. This article explains the installation and configuration process of the XAMPP Apache distribution, and then provides a step-by-step tutorial on developing a simple address book program using the PHP programming language and MySQL database package. In order to comply with the Ontario Skills Competition, this article will use the following coding standards and tools: XHTML 1.0 Transitional, PHP 5.0, MySQL 5.0, and phpMyAdmin 2.9. About XAMPP and Installation Requirements XAMPP is a small and light Apache distribution containing the most common web development technologies in a single package. Its contents, small size, and portability make it the ideal tool for students developing and testing applications in PHP and MySQL. XAMPP is available as a free download in two specific packages: full and lite. While the full package download provides a wide array of development tools, this article will focus on using XAMPP Lite which contains the necessary technologies that meet the Ontario Skills Competition standards. As the name implies, the light version is a small package containing Apache HTTP Server, PHP, MySQL, phpMyAdmin, Openssl, and SQLite. For more details on the packaging and versions, refer to TABLE 1. In order to be able to successfully run XAMPP Lite, you will require 17 MB for the self-extracting ZIP installation archive and at least 118 MB after it has been extracted on a local hard disk or USB drive. TABLE 1: XAMPP and XAMPP Lite feature comparison chart. 1
  • 2. Obtaining and Installing XAMPP As previously mentioned, XAMPP is a free package available for download and use for various web development tasks. All XAMPP packages and add-ons are distributed through the Apache Friends website at the address: http://www.apachefriends.org/. Once on the website, navigate and find the Windows version of XAMPP Lite and download the self-extracting ZIP archive. After downloading the archive, run and extract its contents into the root path of a hard disk or USB drive. For example, the extract path for a local Windows installation would simply be C:. If extracted properly you will notice a new xampplite directory in the root of your installation disk. In order to test that everything has been installed correctly, first start the Apache HTTP Server by navigating to the xampplite directory and run the apache_start.bat batch file. NOTE: Depending on your local Windows configuration, you may be asked to provide network access to the Apache HTTP Server. It is important that you allow network access to the server through your firewall in order to have a functioning server. Next we will test if the server is running correctly by opening an internet browser and typing http://localhost/ into the address bar. If configured correctly, you will be presented with a screen similar to that of the one in FIGURE 1. FIGURE 1: XAMPP splash screen. In order to stop all Apache processes do not close the running terminal application, but instead run another batch file in the xampplite directory called apache_stop.bat. 2
  • 3. PHP Hello World In the previous pages we installed and ran the Apache HTTP Server with success. The next step is to write a simple “Hello World” program in PHP that will test the configuration of PHP under XAMPP. In a text editor, such as TextPad, write the following lines of code: The above code example starts a new XHTML document with the page title set as “Hello World” and then prints a single line of text, Hello World, using the echo PHP language construct. In order to run and test this PHP program, save it into your xampplitehtdocs directory with the file name of helloWorld.php. Then, to view it in your browser, simply type in http://localhost/helloWorld.php into the address bar. If done correctly, you will see your Hello World line of text in the web browser as shown in FIGURE 2. FIGURE 2: Resulting output for helloWorld.php. 3
  • 4. Creating a Database and Table, and Inserting Data Now that we have run and tested Apache and PHP, the next step is running MySQL and creating a database and table which will hold information for our address book program. In order to start MySQL, navigate to the xampplite directory and run the mysql_start.bat batch file. NOTE: Similarly to the Apache HTTP Server, MySQL will also need network access; therefore in order to have a functioning database it is important to allow this access through your local Windows firewall configuration. The XAMPP Lite package contains an application called phpMyAdmin which allows developers to administer and maintain MySQL databases. For the remainder of this article we will be using phpMyAdmin to create a database and table, and enter test data used in the address book program. In order to start phpMyAdmin, you must first copy the phpMyAdmin folder from the xampplite directory and place it into the xampplitehtdocs directory. Before testing phpMyAdmin, make sure that both Apache and MySQL are running by opening their respective batch files: apache_start.bat and mysql_start.bat. Along with Apache and MySQL running in the background, type http://localhost/phpMyAdmin/ into your internet browser. If successful you will be presented with a phpMyAdmin start page similar to the one in FIGURE 3. FIGURE 3: phpMyAdmin start page. 4
  • 5. The first step with phpMyAdmin running is creating a new database. To do this, point to the textbox labelled Create new database and type addressBook as the name of a new database. Upon doing so, you will be forwarded to a screen similar to the one in FIGURE 4. Next, insert a new table in the addressBook database by typing colleague into the table name textbox and clicking the Go button to proceed with creating the table. FIGURE 4: Creating a new table in the addressBook database. Following the creation of the colleague table, you will be required to insert the columns that make up your table. By using TABLE 2 as a reference, insert the necessary columns that will make up your colleague table for the address book. TABLE 2: Table summary for the colleague table. Lastly, with the database and table created, we next need to input some data into the table. Using the fictional information from TABLE 3 on the next page, input the contact data into your own table. NOTE: When inputting data into the table, leave the id field blank because it is set to auto increment to an automatic number on every record entry. 5
  • 6. TABLE 3: Fictional table data for the colleague table. We are now ready to write the PHP program that will connect to the database and display our data in an internet browser. The procedure that we will write this program is to first establish a connection with the database using PHP, then start our XHTML deceleration and meta data, and finally in the body of our page, write a loop that will iterate through each record in the colleague table and display that data in the browser. The PHP block above will connect to our database using localhost as the address, root as the username, and a blank password field. This configuration of root as the username and a blank password is the default that is set when phpMyAdmin is configured and is what we will be using for our examples. NOTE: Although it is perfectly fine to use the default username and password for learning purposes, it is strongly suggested to change the password to something more secure if developing full web applications. Following the mysql_connect("localhost", "root", ""); line of code is another line stating that we will be connecting to and using the addressBook database. Lastly, we will create a variable called result which will contain a SQL query that will select all records from the colleague table. 6
  • 7. In the above code example you will notice that the PHP code block, contained within <?php and ?>, is started and then ended before declaring the XHTML document. Remember that in the “Hello World” example earlier in this article we also had a PHP code block within a XHTML paragraph tag. This is important to note because XHTML and PHP can interchangeably be used within one another. This concept will also be shown when we write a PHP loop to retrieve all the records from the database and display it in a XHTML table. Insert a couple new lines after the closing </head> tag and then type in the following code: This new addition to your code will simply start the body of your document and then place a new XHTML table, along with a new table row followed by five table headings: ID, First Name, Last Name, Telephone, and Email Address. 7
  • 8. Next we will create a new PHP code block in which we write a while loop that goes through each database table record and outputs each piece of data in a new XHTML table cell: This loop will write a new table row for each record by printing the <tr> tag and then also write the id, firstName, lastName, telephone, and email into its own respective table cells using the <td> tags. Finally, before ending the loop, the table row is closed by printing out </tr>. The PHP code block is concluded by freeing the memory with mysql_free_result($result); and closing the database connection with mysql_close();. The majority of the code has now been written, however, to properly end this XHTML document we will need to insert a few more closing tags: You may refer to the next page for complete code of the address book program. 8
  • 9. 9
  • 10. Now that you have created a database and table, inserted some data into that table, and written a program that reads the data using PHP, all that is left to do is test, and if required debug. Making sure that the Apache HTTP Server, along with MySQL are running, open up an instance of your internet browser and type in the location of your address book PHP file. For example, if you created an addressBook folder inside the htdocs folder, then the path to run the address book program would be: http://localhost/addressBook/index.php. If done correctly, you will be presented with a page similar to that of the one in FIGURE 5. This figure shows the address book program running with a XHTML table showing the data from the colleague table. If you encounter an error, please review and compare your code with the complete code provided on the previous page. Lastly, to stop and close all processes run the apache_stop.bat and mysql_stop.bat batch files for the server and database respectively. FIGURE 5: The address book program displaying contact information from the database. Conclusion Throughout this article you have been shown the beginning concepts that will allow you to set up a development environment, create and administer a database, and write a program that connects to a database and retrieves data. Although these concepts are important ones, they are in no means the end of an application. By using the address book program as an example, there is still a lot of features that can be implemented in such an application. Features such as editing contact information, deleting contacts, adding new contacts, and being able to email contacts through a form are all additions that can be implemented to the example used in this article. Challenge yourself, use this article and other resources as a jump-start and try adding other capabilities to your own address book program! 10