XP Home Support Forum - XP Home Help Forum Index
Author Message
<  Building Web Sites.  ~  Building web applications Lesson 1
lowster11
PostPosted: Wed Jun 11, 2008 11:12 pm  Reply with quote
Site Admin


Joined: 14 Sep 2005
Posts: 83
Location: Sacramento

In this course, you'll use both PHP and MySQL to create a dynamic Web site that calls information from a database to show information that the user chooses. You'll also create an administration page for someone (the customer or other employee) to update and manage the Web site without needing to know any programming at all.

To create dynamic Web sites, a variety of programming languages can be used. The following list briefly introduces these technologies and compares them to PHP:

PHP ( PHP: Hypertext Preprocessor): PHP is a structured, server-side language (and one of the main focuses of this course). This means that it has rules (structured) and all of its code is run on the server. It can be run on Unix- or Windows-based servers and can integrate with databases, such as MySQL, PostGres, and others.
The name PHP actually stands for PHP: Hypertext Preprocessor. I know it's weird, but I only report it, not create it!

ASP ( Active Server Pages): ASP is a proprietary system used only on Microsoft IIS (Internet Information Services) servers. It's not a language like PHP, but uses VBScript (Visual Basic Script) or JScript to create and run ASP. All code is run on the server. The pros of using ASP include the ease of learning VBScript if you already know how to program in Visual Basic. If you're running a Microsoft server, it's easy to get up and running, but ASP is said to be slower, more cumbersome, and less stable than PHP. Plus, there are a limited number of components built into ASP, so you may end up buying additional components if you need to use features not included. And of course, IIS servers tend to be more expensive than Unix-based servers are.
CGI/Perl : Perl is a high-level programming language, originally used to build and test programs. Perl is a very tried and true language. It's been around since the late 1980s. The flexibility and complexity of Perl makes it easy to write code that another author or coder may have a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has all the good functionality of Perl, such as constructs, syntax, and so on, without being as complicated as Perl.
ColdFusion : ColdFusion is both a language and a database. It's an integrated system designed for nonprogrammers; therefore, it's generally easier to get started with, but may limit growth at some point. PHP, on the other hand, requires more programming knowledge initially, but it's faster and more efficient for complex programming tasks and trying out new ideas. PHP is generally referred to as more stable and less resource intensive as well.
JavaScript : JavaScript is a client-side programming language. This means that the code runs on the computer of the person viewing the Web site. The advantage of a client-side programming language is the speed and lowering of the server's work. Its biggest disadvantage is the unpredictability of the systems that may be running your code. Some people have JavaScript turned off on their system and older computers may not be able to handle it.
Each of these programming languages has its strengths and weaknesses. By using PHP (or other server-side language) to write your pages, you know that what works on your system will work on anyone's system (as far as coding goes) because you're running the code on the server, not on your local machine.

In fact, you can't see PHP code in any PHP page unless you have access to the server. When a page is served that contains PHP, the server processes the instructions and sends normal HTML to the client requesting the page.

PHP is inserted within the HTML code, and then stripped out as it's processed, so a page with PHP in it looks like this when you create it:

<html>
<body>
Today is
<php>
.
</body>
</html>
When viewed as a source file from the computer requesting the file, however, it looks like this:

<html>
<body>
Today is Saturday, the 10th.
</body>
</html>
And of course, on-screen, it will look like this:

Today is Saturday, the 10th.
However, the PHP code provides the current date when the file is run, whereas the HTML file still says the same date ? thus, the power of dynamic Web sites!

PHP is most commonly found on Apache and Unix Web servers, but it can be installed on IIS, Netscape Enterprise Server, and others. If you don't have your own server, you can easily set up an account at any number of Web hosts. Ask if PHP is installed, as well as MySQL (which is covered in the next section of this course).


Last edited by lowster11 on Wed Jun 11, 2008 11:15 pm; edited 1 time in total

_________________
Sacramento Search
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lowster11
PostPosted: Wed Jun 11, 2008 11:12 pm  Reply with quote
Site Admin


Joined: 14 Sep 2005
Posts: 83
Location: Sacramento

Even before you get your Web site, you need to start planning for it. This section gives you pointers on where you might host your Web site, but even before you set it up, you need to plan what you'll be doing.

In this course, you'll create a demo Web site for a property management company (this is a company that offers properties for rent). To that end, you need to consider what the company needs for its Web site and how you plan to go about getting what it needs. You need the following:

Static home page and other various pages: These can be created in HTML and are beyond the scope of this course other than to note you may integrate static and dynamic pages in one Web site.
Dynamic admin page: This page needs to be password protected and will allow the Web site owner (a noncomputer person who is the property manager) to manage his properties. As such, this page needs an interface to list properties currently on the Web site, so the properties can be active or inactive. The property manager will have rentals on a recurring basis, so once the property is in the database, it will be available for future activation when it's available for rent again. In addition to activating existing properties, the property manager needs to be able to edit text fields, upload photos, add new properties, and delete old ones (that he no longer manages).
Dynamic properties page: This page is for the public and allows visitors to view properties currently for rent and search by preferred needs, such as two or three bedrooms, city, and preferred rent amount.
Each Web site you create will have different purposes and needs, but before anything else, you need a plan. Start with the needs of the visitors and the needs of the company. Understanding your goal shapes each future decision.

If it's your own company, you can simply manage your Web site through the backend (as you'll learn when you set up your database). However, this example assumes you're creating a Web site that nontechnical people will manage. If you approach your Web site as if you'll turn over all management of the site to nontechnical people, you can later replicate the site for another client.

In implementing any plan, if this is a brand-new Web site, start by creating the look of the Web site based on what will work best for your visitor demographics. If it's an existing Web site, you can take the existing look, and then add the dynamic code to it. Either way, the procedure is to create the static look first, and then code the dynamic portion of the site.

TIP
One other way to create a dynamic Web site is to create the code without the site, displaying database information on a plain white page, and then adding the Web site code around it. This allows the graphic and design people to work on their portion, while the programmer works on her section, and then integrates into the correct look.

_________________
Sacramento Search
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lowster11
PostPosted: Wed Jun 11, 2008 11:13 pm  Reply with quote
Site Admin


Joined: 14 Sep 2005
Posts: 83
Location: Sacramento

The example in this course is an existing company, Mesa Verde Property Management, which uses a completely static site. This means that every time the company has a property available for rent, the programmer has to manually edit the properties.html page to add that property, its photos, and text to the Web site -- even if the rental properties' information remains the same, except for the rental and deposit information.


Mesa Verde has its look, has its Web site, and has the following static pages:

index.html: The main page, of course. This will remain static, although you may want to consider a dynamic page to announce new changes on your Web site or other changeable information.
properties.html: This will be the new dynamic page for the site. Instead of static information, you'll code it to pull active sites from the database and display them for all properties, as well as have a search feature and a detail feature for more information on specific properties.
contact.html: This will remain a static page for the Web site, although if you're creating a site for a customer, you might want to make this a dynamic site so that the customer can change the information if she needs to. Whether to do this also depends on if the customer's information changes a lot. owners.html: This will also be a static page with general information on how the company interacts with property owners.
renters.html: This will remain a static page with general renter information.
application.html: This will remain a static page with a form, although you'll create the form handling using PHP.
thanks.html: This is a static page displaying a "thank-you message" after an application form is filled out. You'll replace it with a dynamic PHP form-handling page.
You'll add two new pages to the existing list:

applicationpost.php: This will take information from the application.html page and send it via e-mail to the site owner as well as display a "Thank-you page."
admin.php: This will be where the client administers her site and will include a utility for uploading images, editing, adding, and removing properties.
Notice that the new pages have a .php extension rather than an .html extension.

In some systems, you can also program .html pages to be recognized as .php pages, but in doing so, every page is looked at by the PHP preprocessor on the server, thus slowing down the site overall. By using separate pages with separate extensions, you can be clear on which is a dynamic page and which is a static page, making it easier for you to maintain the site. In addition, only the PHP pages are processed for code on the server, thus speeding up the site.

_________________
Sacramento Search
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lowster11
PostPosted: Wed Jun 11, 2008 11:14 pm  Reply with quote
Site Admin


Joined: 14 Sep 2005
Posts: 83
Location: Sacramento

In most basic terms, a programming language can allow you to create some pretty cool pages. But if you're eBay or want to be eBay, where do you store all that data? In a database, which is what MySQL is. In addition to MySQL, other databases include Microsoft Access and SQL (Structured Query Language) Server, and Macromedia's ColdFusion, which is both a database and a language and quite proprietary, but nice in its own way.

A database is a collection of data, stored in a table format with fields and records represented in the columns and rows of the tables as follows:


PropertyID Address City State Zip
1 123 Main Street Mesa AZ 85201
2 321 E. University Tempe AZ 85224
3 567 N. Central Phoenix AZ 85004



The property project you'll use during this course is a fairly simple one-table database, similar to the preceding example, but you'll add more fields. The names across the top are the field names, and you'll need to consider all the possible fields your project will require. The rows are the records in the database.

This example is actually a flat-file database, but all of the databases mentioned here are relational databases, which means that you can have several tables of information that are all related to each other. If later, you wanted to expand this database to manage the property owners and the renters, you could create an owner table and a renter table and relate them to the property table for a variety of reports.

In creating your database, before you even touch the computer (you'll learn how to create the database later in this course), you need to start thinking about the database structure. In the example for this course, you're managing rental properties, so the following field list includes some definite fields you need in your table:

PropertyID
Active/Inactive
Street Number
Street Direction
Street Name
Street Type
Apartment Type
Apartment Number
City
State
Zip
The actual fields and why they're broken down so far will be further explored in a later lesson, but as you're considering your project, start jotting down fields that you need for your database because you'll think of others along the way.

_________________
Sacramento Search
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
lowster11
PostPosted: Wed Jun 11, 2008 11:14 pm  Reply with quote
Site Admin


Joined: 14 Sep 2005
Posts: 83
Location: Sacramento

To complete this course, you need the following:

A Web account with PHP and MySQL support
A text editor
For your Web account, there are a variety of options available.

Simply Google for mySQL PHP hosting, look up companies at Top 10 Web Hosting, or consider using one of the following:
hosting.searchen.com: Offers PHP and MySQL
dotservant.com : Offers PHP and MySQL support on a Unix Server
Crystal Tech web hosting, inc. : Offers PHP and MySQL support on a Microsoft Windows server
When you write PHP, you can use any text editor, just as you can in HTML. For your text editor, you can use Notepad, but as you can see in Figure 1-2, it's not very distinctive. All the text is in the same color and style. It doesn't distinguish between the code tags and the text, as HTML and PHP editors do.


A very fancy (and expensive) answer is Dreamweaver.



EditPlus and Dreamweaver both have a 30-day trial period and color code the text to make it easier for you to see your code as you write it, but Dreamweaver is a more advanced interface and more expensive. EditPlus may be easier for beginners.

_________________
Sacramento Search
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
All times are GMT - 7 Hours

View next topic
View previous topic
Page 1 of 1


XP Home Support Forum - XP Home Help Forum Index  ~  Building Web Sites.

Post new topic   Reply to topic


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Template: Ad Infinitum