| Type: |
Code 
|
| Level: |
Intermediate
|
| Date: |
2007-May-05
|
| Visited: |
1169 times
|
| Rating: |

|
| Author: |
Alex Plumpton |
|
|
This is a lesson that will show you how to transform variables from Flash clip to PHP script.
Settings of the Flash player
Make an Input Box with the Text tool. You have to give a name for the impute box in the text properties pannel. You can choose the name by yourself but you have to remember it because you will use it in the PHP script.
I made 3 Input boxes. I named them "name","age",and "eye". I guess they are easy enough to be remembered?
Ok now you will need a button to open the PHP page. To open a new page in Flash use the action script and especially the variables getURL().This is the code:
submit.onPress = function () {
getURL ("getVars.php", "_blank", "POST");
}
|
Interpret the code:
1. getVars.php is the name of the PHP file witch you are going to use;
2. _blank makes the butting which is opening the page;
3. POST is the method in which to transfer the variables. The other option is GET.
The PHP code:
<?
// Receiving the variables.
$name = $_POST['name'];
$age = $_POST['age'];
$eye = $_POST['eye'];
// Printing out the variables.
print "Your name is ". $name . ".";
print "You are ". $age ." years old.";
print "You have ". $eye ." eyes.";
?>