PHP AND JAVA SCRIPT GETTING STARTED




Well since the net seems to be the way the way things are going somewhat in terms of coding I thought i'd check out how you actually go about doing it. I suceeded so I thought i'd share some of the gotcha's I encountered. This tutorial doesn't attempt to be definitive it is merely a overview to get you going you will need to fill in some of the details yourself. I also assume you are at least somewhat familiar with programing languages.


So here are the steps one would need to take to get going writing web apps. Note all the software I used in this tutorial is free and open source so other then finding a web site host you won't need to spend a penny.


The programs you need to download are the Apache server, PHP, Mysql and PHPmyadmin. So download these apps but don't install them yet. Use the text editor of your choice to actually code in. I use note pad++ it's free open source and it supports , html, javascript and php and a ton of other languages for that matter but thats another story. Make sure you download the latest versions of the software.


Use this link to handle the installation this is what I did. Be sure to follow the instructions to the letter. If you botch it, which you may, be sure to uninstall the programs and manually delete the directories containing the programs. You may also need to delete the config files mentioned in the tutorial from windows to get a clean reinstall. Just be carefull and follow the directions the first time and save some greif.


http://www.thesitewizard.com/apache/install-apache-2-windows.shtml


If you've followed the tutorial above you should have the apache server and psp up and running. Now to install mysql just run the install and follow the directions. Simple but theres a catch you need to go to add remove programs and click on the php entry. Press change, go into the extensions and be sure to include mysql and mcrypt if there not included already. After this Reset the apache server like you did in the tutorial.


paste the text below into a file with tester.php extension and test it from your brower window

<?php phpinfo(); ?>

The path to run it would be -- http://localhost/tester.php You must place the file in the htdocs directory. (It's inside your Apache Directory)


The blue screen that comes up gives information pertaining to extensions just be sure mysql and mcrypt are there and you should be ready to go.


The point of all this is so you can test your app from your own computer without having to upload via ftp all the time. Also you get a ton more debugging information then you would just deploying your webpages "live". This is way faster and somewhat more like a traditional compiler.


Now i'm explaining nothing here in terms of the coding theres a ton of tutorials around that can help you get started. The one below is good for php.


http://www.tizag.com/phpT/


There are a ton of good html and Javascript tutorials on line. I would recomend getting some good textbooks about php, javascript and html as these are generally far more polished then online tutorials. There is some good ones at my local library there probably are at yours as well if your budget is a concern.


Now a ton of people have explained how each individual language you use to design webpages works, I found it hard to figure out how they interact together.


Html is essentially static when used alone. It is not a programming language per say, it's best to think of it as more of a typesetting language suitible to the display of text or graphics. The syntax is usually simply and seems designed to be quickly parsed.


JavaScript is a programming language used to manipulate html. For example you could use JavaScript to verify the characters in a text feild. It can also be used to manipulate html events suchs as On_Load event which is called when a page is loaded for example.


Both JavaScript and Html are considered the Client Side of web programming. Meaning that this is the code that runs on the users computer not on the webserver. So it's important to note that if you click refresh on the page all information you entered before would be lost. You can use cookies in some cases to get around this but this is highly limited and not effective for truly interactive web pages. So the html and Javascript in a page are what is actually sent to the viewer of the page, this is translated into the graphical content you see on the screen.


You need psp or another server side scripting language to create dynamic content. When people say server side they are taking about code that runs on the server.

<?php phpinfo(); ?>

Consider if a user clicked on a page containing the program above. What happens is the server runs the tester.php program and generates html and java script and sends that to the user. In this case a web page is generated containing information about your psp setup. Note if you look at the page source in your browser you will not see the psp program only the html and javascript it generated. So php is basically just a programing language designed to generate html for webpages.


Mysql is also on the server side it is just a data base. You use php to communicate with Mysql to get data in and out of the database. You can then use php to generate webpages based on the content.

Javascript variable to PHP variable


Form variable to PHP variable


Both of the above are not possible unless you reload the page to generate new content based on the form or Javasript variable. This is a important point for newbies to remember. The major thing I find different about web programming is the fact that variable communication is simply not as strait forward due to security concerns. You often need to do some crafty stuff to get data to do what you wan't.


Check out this tutorial for some neat tips. It also gives a good idea of what you can and can't do.


http://www.skytopia.com/project/articles/compsci/form.html


Note: I am no where near as skilled at web coding as I am in C. So please point out any mistakes I have made in this tutorial if your a expert web developer and I will change it. Just remember this is intended to help people get going and is not intended to be definitive in any way. So if your experienced try to think back to what confused you when you started I made this tutorial to sort out some of the things other newbie tutorial's didn't explain.


Also I've included a list of texts that may be of interest to web developers. Note I have not read these texts myself but I will consider purchasing some of them.


PHP and MySQL Web Development (4th Edition) (Developer's Library)


PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide


Practical Web 2.0 Applications with PHP


Programming PHP


More Programming Tutorials