|
||||||
|
||||||
Tutorial - Intro to PHP & Flash

Free
Flash PHP Tutorial
![]()
This tutorial gives you some basic information about PHP and how to setup PHP to work with Flash.
Flash can read information stored on-line but cannot write information to a remote server. To write data to a remote server (a place where web pages are stored) you need a server side scripting language. PHP is such a scripting language. PHP not only enables you to create Dynamic Content but enables it to be saved automatically so that next time that web page is viewed it not the same as the previous viewing but now contains the new information.
Dynamic content simply means something which changes. A hit counter is a simple form of Dynamic Content. Every time the page is loaded the number goes up by one and this new updated number is then saved. A Forum or Bulletin Board would be an advanced example of how PHP could be used to create web content. Every time you return to the Forum or refresh a Forum page the PHP will display the new messages.
The Forum on this site is built with PHP and the messages are saved via a PHP to a database. Every time you visit the Forum the PHP reads the database to see what to display on the web page. These pages are dynamically created every time you visit the forum.
PHP is free to use and the goal of the language is to allow web developers to write dynamically generated pages quickly. Hence it has become extremely popular and one of the most used languages on the web. It is an extremely versatile and powerful language.
PHP can be used in conjunction with Flash or it can be used to display data directly on a web page. So PHP is not specifically a Flash technology, it is just that you are able to access PHP via Flash.
Some alternatives to PHP are Microsoft's ASP/VBScript/JScript system, Macromedia's ColdFusion system, Sun Microsystems' JSP/Java system, and the CGI/Perl system.
Example:
Download the Flash file
Int 39a
Example of Flash - PHP hit counter as explained in
the next tutorial: Flash PHP Hit Counter
Note: To test the hit counter above press the Refresh Button at the top of your Browser:
(Usually F5).
The count number should go up by one.
Step One: A PHP Enabled Server
Note: If you already have a PHP enabled server skip this step.
Flash runs in the Browser. This is why the viewer has to have the Plug in to be able to see the Flash Movie. Most web Browser now come with the Flash Plug In already installed. The point is that it is the Browser on the viewers local computer that is doing all the work. This is why Flash cannot save file to the web server - it is not running on the server but on the users computer. The users computer is called the Client as opposed to the Server.
PHP is a Server Side Script. This means that the script runs on the web server before the browser reads the web page.
So PHP works like this:
Important: Check to see if your Remote
Server is PHP Enabled
Before you can use PHP you need to make sure your web server is PHP Enabled. Without this you cannot run the PHP script. Almost all web providers will offer a PHP Enabled Server. So before you do anything check that your provider offers this service. Some web providers offer this by default and other you have to request for them to enable (or activate) it before you can run any PHP script. Some providers may charge you a small amount to do this.
Step Two: Viewing File Extensions on a PC
Note: If your computer is already set so that you can see file extensions skip this step.
To be able to use PHP effectively I recommend that you set your PC (see note on Macs below) so that you can see the file extensions. That way you can easily tell what file is PHP, what file is a Text file, what file is a web page etc.
To be able to see what you are doing you will need to make sure your PC is set so that you can see the file extensions. That is the letters which follow the file name and tell the computer what type of file you are looking at. For example:
By
default when you buy your computer these file extensions are hidden. But to
complete this tutorial you will need to be able to see these.
In a PC:
Note: In some older version of Windows you may find Folder Options under a different Menu such as: View > Folder Options > View
In a Mac
I am no Mac expert but from what I understand Macs do not use the same file extension system. Adding the three character extension to a Macintosh file name does not hurt on the Macintosh, it has no effect. But it does make moving files to PC (or web server) easier.
Step Three: CHMOD Settings
CHMOD stands for: Change Mode
By default files that you upload to your web server are set to read only. That means that someone viewing the page can read it (or more accurately the Browser reads it) but not change it. You can only change the files on your web server if you have an FTP program and you have the correct access rights such as the correct Password and User Name
For the PHP script has to be able to both open and save files on the server. If the PHP cannot do this there is not much point in having a server side scripting language. This is where the CHMOD settings come in. CHMOD setting enable you to set specific files as readable and writable. CHMOD setting are usually referred to by a code. The default setting for web pages is: 644
Default CHMOD Setting.
For a PHP script to be able to read and write (save) a file you will need to be able to change the CHMOD setting for specified files to: 666
CHMOD set to 666 so that the PHP script can save the file.
CHMOD and Web Providers
Some web providers may have an on-line FTP program that enables
you to select a file and change its CHMOD settings. Most web providers will
not offer this service!! But no harm in asking.
CHMOD and Web Editors
Some Web Editors will
allow you to view your online files and change a specific files properties
such as the CHMOD settings. Most web editors will not allow
you to do this!! Even sophisticated top of the range web editors like Dreamweaver
will not let
you change the CHMOD settings. But there is no harm in looking. Open any web
editors that you may have on your computer and look up CHMOD in the help menu.
Update: Dreamweaver 8 now enables you to change the CHMOD setting. Upload the file you want, view the file on remote view, right click (Mac Ctrl click) and select: Set Permissions
CHMOD and FTP Programs
You guessed it: Many FTP programs do not let you change the CHMOD settings
but many do!! Again if you have any FTP programs installed on your computer open
it and check the Help menu. If you don't have an appropriate FTP program you
can download one from the Internet. Before downloading and installing an FTP
program try and look at the program notes as many FTP programs do not allow you
to set the CHOMOD properties.
The FTP program that I use to set the CHMOD file settings is: SmartFTP This program is free to educational and personal users and in my opinion is a very good program but a bit fiddly to set up and use the first couple of times.
As with all FTP programs they enable you to see your files on line like this:
Online files in Smart FTP.
To set the CHMOD I simply need select the file I want to change then right click and select CHMOD. A dialogue box appears similar to the one above. To see a Movie of how to change the CHMOD settings in Smart FTP: Demo (large file).
There are loads of other FTP programs and many are free but it is hard to find a freebie FTP program that allows you to change the CHMOD settings. If the program above is not suitable you may want to so a search Shareware.com as they have an excellent selection of freeware and shareware: Shareware.com
Setting Up your FTP Program
An FTP (File Transfer Protocol) program is
a file management system and is not that different to something like My Computer
or Windows Explorer. Except that it enables you to manage files which are stored
on a Remote Server such as a Web Server. Some years ago you needed to have
an FTP program to move (upload/download),
delete and rename your web files to and from your local computer
to your web site. This capability is now usually built into most web editors.
So for example you can now do most remote file management tasks directly from
a program like Dreamweaver.
Like web editors an FTP program not only needs to be installed but it has to be set up. After installation you will need to set up the FTP program to link to your web site. For this to happen you need three bits of information:
If you do not know these three things ask your web provider as they will know.
Using an FTP Program to set the CHMOD
Once you have set up the FTP program correctly you will be
able to upload files to your web space and view the files that have been
uploaded. It does not matter if you continue to upload your files form your
web editor or use the new FTP system. What is important is that once they
are uploaded that you can see the files. Once you can see the files you can
select the file/s that you want to change the CHMOD settings on and either
right click and go to CHMOD or find CHMOD in the menu system. You will then
find a dialog box that will enable you to change the read/write settings
for the selected files:
![]()
CHMOD Dialog box.
That is all there is to it.
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
40944 visitors to this page since
Nov 04 •
|
|
|
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|