# PHP

With PHP you can exchange information with databases, send data by email and execute PHP code on the webserver.

PHP code must be executed by the webserver. It will not work on your local computer. To run PHP code you have to upload PHP files and Flash file to your website and open Flash SWF file from the website.

### Executing PHP Code

To execute PHP file click "More Actions" when editing "On Click" action. Click "Send Form" and enter the name of the PHP file. Flash player will call the PHP file in the background (without opening it in the browser window)

### Passing variables to PHP

All variables that have been initiated in ActionScript will be sent automatically by POST method to the PHP file. For example if you draw edit field and enter the text "Hello" the variable will be sent as:

Edit1=Hello

In PHP you can access the variable with:

`$_POST["Edit1"]`

### Passing variables from PHP

PHP code must return variables by echoing plain text in the following format (known also as "query string"):

Variable1=Value1&Variable2=Value2

to echo variables from PHP back to Flash use "echo" function:

`echo "Variable1=" . $Variable1 . "&" . "Variable2=" . $Variable2;`

After PHP file has been executed, returned variables will be initialized in ActionScript. You can use them like other variables in ActionScript for example:

`Edit2 = Variable2;`

### Creating PHP Code

You can use your favorite PHP editor or use Flash Designer "Movie" > "PHP" command to manage your PHP files. To export PHP files choose "File" > "Export Web Page" command.

### PHP Basics

PHP code must start with <?php and end with ?> Use // or /* */ to add comments to your code. You should not put any HTML tags as they will not be displayed.

To learn more about PHP visit W3 website: