turning php code into a beta website

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: turning php code into a beta website

Post by califdon »

Let's start at the beginning.

You now have Apache web server running. In order to see any web page (html or php) when you enter "localhost" in your browser, the html or php file must be in the Document Root folder (==C:/xampp/htdocs/ or whatever you have set Document Root to be in the Apache configuration file (httpd.conf) ). If your files are in subordinate folders, you would have to include the path when you enter it in your browser, so maybe "localhost/myfiles/index.html" or something. It is not good to leave ANY folder in the Document Root or subfolders without a file named exactly: "index.html" or "index.php" because if there is no such file, you will see the index of files, as you have already seen. That's probably not a problem on your own computer, but it is asking for disaster on a server that's accessible over the Internet. It allows absolutely anyone to see and copy your files and perhaps then do more damage, with that knowledge.

You cannot ever use a word processor to work on files on a web server, unless you explicitly save them as plain text files. You should immediately form the habit of either using an HTML Editor (several free ones are available to download--just Google for them) or using Notepad. This goes for the configuration file (httpd.conf) and html and php files.

My suggestion is this: open Notepad, enter the following--no more, no less--and save it in your Document Root folder (not in any subfolders) as index.html:

Code: Select all

<html>
<head>
  <title>This is a test</title>
</head>
<body style="text-align:center; font-size:18pt; font-weight:bold;">
  THIS IS MY FIRST TEST PAGE
</body>
</html>
Now you should be able to go to "localhost" with your browser and see the page.

Once you have that working, you can try a php script: again open Notepad, enter exactly the following and save it in your Document Root folder as firstphp.php:

Code: Select all

<html>
<head>
  <title>First PHP Script</title>
</head>
<body style="text-align:center; font-size:18pt; font-weight:bold; color:#0000FF;">
<?php
echo "THIS IS BEING SENT FROM MY FIRST PHP SCRIPT";
?>
</body>
</html>
Now you should be able to go to "localhost/firstphp.php" with your browser and see the page.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: turning php code into a beta website

Post by JAB Creations »

It sounds like you're getting in to the territory specific to the PHP/MySQL script that you're working with. I highly recommend heading towards their website and following whatever installation instructions they may have.

I also highly recommend using Windows Explorer. I moved the start menu shortcut to instantly easily accessible parts of Windows XP (Quick Launch and inside of my start menu) so you should get used to being able to quickly get around folders on your computer without having to open new windows constantly. Self-organization is critical towards having a sense of where you are in order to concentrate on what you desire to accomplish.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: turning php code into a beta website

Post by califdon »

hvnlydaze wrote:within the folder i put into htdocs there are 2 other folders and 5 files one of the folders says demo and has 1 file (xml)

in the other says sql and has 2 files 1 for waypoints and one for caches not sure if that matters
You're making it much more complicated for yourself than is necessary. Eventually, you may want to use subfolders and have a bunch of files that are eventually going to be on a web site, but don't start out that way! Until you get the server working and have a grasp of how to do the basic things like edit a file without using Word, just stick with the demo files that I showed you.

To answer your question (above), I will quote my favorite computer language instructor, who told me many years ago that the first two rules of programming are:
  1. Everything matters.
  2. Never give up.
That philosophy has served me well for over 20 years of programming.
Post Reply