#native_company# #native_desc#
#native_cta#

Using PHP and MySQL with Flash Page 4

By Jeffrey F. Hill
on December 14, 2001

User Registration

PHP used in the first Registration section

$query = "INSERT INTO $table (Name, Object1, Object2, Object3, Comment) VALUES ('$RegName' , '', '', '', 'Hello')";
$result = mysql_query($query);
This will create a new entry in the database for a new user. The only value we have to worry about for now is the Name variable which will be set to the Name entered in the Flash Movie in the text field Named RegName. All other variables will be set later. The name column was defined as being unique when we created the MySQL table so there can only be one User with that Name. If someone else tries to register with that name they will not be able to. The second line of the above code is what actually performs the query. The only thing that’s returned to the Flash movie at this point is a message to the user proclaiming that registration was successful or failed if the Name already exists in the database. You can see how this is done in the actual script.

Flash Actionscript Used in Registration

All that is required in Flash at this point is to have one text field named RegName. Then either on a button or Frame command include this code.

on (release) {
    Status = "Beginning registration Process... Please Hold";
    loadVariablesNum ("Register.php?RegName=&"+RegName, 0);
}

I have an extra text field named Status, but this is optional. Notice on the LoadVariablesNum command I specifically pass the variable RegName to the PHP script. This is not necessary, adding “Post” will do the same thing. It’s just sometimes easier to keep track of what’s passed to a script in this way. After a user has entered their Name and hit the register button the LoadVariablesNum Command will call the PHP script, pass whatever was entered in the RegName Field to it and execute the statements.

1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9