Archive for Chapter 2

Are you have trouble understanding how to use your Web server?

When you use xampp, you are connecting to a Web server that is located on your own computer rather than somewhere else in the world. Just as other Web servers have domain names (for example http://www.mikeokane.com) your local Webserver has a domain name: http://localhost. The procedure to use your Web server is as follows:

First, like any Web server, the server must be running so that you can connect to it. To run the server, double click the apache_start program in your xampplite folder. You will see a DOS (Console) window with the mesage that Apache 2 is starting..). That means your server is now running (don’t close this window – you can minimize it).

Now you can connect to your server and open Web page, and run PHP programs. To do this open a Web browser (Firefox, Internet Explorer, Safari, Chrome, Opera. etc). Type the URL tof the file you want to open (this is also described in detail in Chapter 2).

Let’s start with something in the samples folder, for example welcome.html. The samples folder is located in the xampplite/htdocs/webtech folder. The URL to this folder is http://localhost/Webtech so the URL to welcome.html is
http://localhost/Webtech/samples/welcome.html If you type this address you will see the welcome document displayed in your browser window.

Similarly your coursework folder is located in the xampplite/htdocs/coursework/webtech folder. The URL to this folder is http://localhost/Webtech so the URL to myFirst.html in you chapter02 folder is http://localhost/Webtech/coursework/chapter02/myFirst.html

Do you see the connection between the actual location of each file and the URL? The actual location is in some folder inside the htdocs/Webtech folder. So when you want to edit your files ina text editor, you will
open and save files in locations under this folder. The URL to these files begins with http://localhost/Webtech followed by the folder names and file. Use the URL to view these files in your Web browser.

If you get a message Object not Found or something similar, it means that you did not type the correct URL, or you did not place your file in the correct location.

If you connect to a PHP file and see the PHP code instead of the results, it means you are opening your files using Windows Explorer instead of typing the URL to the Web server in your Web browser’s address box. You
must open your HTML and PHP files using the URL, begining with http://localhost/Webtech

Note: If you are using a Mac or Linux computer, you must first install the Webtech folder – instructions are provided to do this on the CD and Web site.

Advertisements

Leave a Comment

My browser displays PHP code instead or runnning the program!

That’s because you’re not using a URL to connect to the PHP file. Most likely you are opening your HTML or PHP files by double-clicking them in Windows Explorer. When you do that, the HTML file looks fine but the PHP shows the actual code instead of running. And that’s because you are not using the Web server (even though you may have started the server). To connect to the server you can’t open the .html file in Windows Explorer, you must open the file as a URL in your browser so that the browser will then call the server.

You always know whether you are using the server by looking in the address window in your browser. If the address begins with http://localhost then you are using the server. If it begins with the word file:// followed by a drive letter and file path then you are not using the server..

So .. to do this correctly, don’t double click the file in Windows Explorer. Instead start your Web browser if it’s not already running and type the URL in the address window, for example:

http://localhost/Webtech/coursework/chapter05/modify1.html

If you get a Not Found message, that’s because you didn’t start your Web server first 🙂
Mike

Leave a Comment