- Forms and Interactive Scripts
- WordPress, Drupal, Joomla & Other CMS's
- Custom PHP/MySQL Database Systems
PHP Scripts for Forms and Content Management Systems
PHP can be used without a database to do many things. A database is needed if you are storing information which will be retrieved on later visits (such as text for a webpage or user account information). But for something like a contact form or navigation system where the information will be processed immediately, no database is necessary. In these cases, PHP can be used to perform calculations and data validation or re-route the user to the appropriate page. An HTML may incorporate PHP code snippets to provide specific functions or the entire site may use PHP to generate HTML pages.
Javascript can be used to do many of the same things PHP code snippets do, but, because it is processed on the user's computer instead of the server, it also provides a level of interactivity that PHP can not. PHP can be used to set up a page or to change things once a user has submitted a form or clicked on a link. But if you want dynamic forms that change what's displayed on-screen as the user enters information, you'll need to use Javascript. The Real Cost of an Employee calculator on this site uses PHP on the back-end, but Javascript updates information on screen as the user enters data, providing immediate results as people enter or change their information.
If you've ever filled out a form online and had an alert box pop up right away because something was entered incorrectly, the form probably used Javascript. If you've filled out a form and sumitted it, then been given a list of errors and sent back to correct them, that was probably done with PHP.
The big difference between the two is that Javascript is processed by the user's browser, while PHP is handled by the server. This means a visitor can disable Javascript. They can't do that with PHP, so your code should run regardless of how the end user sets up their browser. If your website depends on Javascript to function (especially if it creates navigation elements), you'll need to test for Javascript support in the user's browser and include replacement code or a user alert if it's been disabled (or better yet, for things like drop-down menus, replace them with CSS).
