Trying to learn flash and php and take help from a book “php for flash” and there is a registration form where the user will input the fields and it will displayed in a dynamic text field.The three fields are Name , Email and Location and each has a var name in the flash just like the Name field has a Var = name, The Email field has a Var = email, and the Location field has a Var = location . The dynamic text filed has a Var=status.
But the input data is not showing . Can anyone have some time to look into the code? The AS is old. There is a submit button on this button the code is just like this
on (release) {
// Reset Status message
status = "";
// If all form elements have been filled out...
if (name != "" && email != "" && location != "") {
// Submit the data to our PHP script using the POST method
loadVariables ("register.php", this, "POST");
// Display the loading frame while data loads.
gotoAndStop ("Loading");
} else {
// Otherwise, inform user that all fields are required!
status = "All fields are required";
}
}
On the Movie Clip that represent the form this is the code
onClipEvent (data) {
// Data finished loading.
// Let's display it!
this.play();
}
Here is the php file named “register.php”
<?
/* MySQL details */
$dbHost = "localhost";
$dbUser = "yourusername";
$dbPass = "yourpassword";
$dbName = "phpforflash";
$table = "downloadLog";
/* Attempt connection to MySQL server */
$link = @mysql_connect($dbHost, $dbUser, $dbPass);
/* If connection wasn't successful... */
if (!$link) {
/* Return error information to Flash and quit! */
print "&list=" . urlencode("<b>Error:</b> Could not conenct to database") . "&";
exit;
}
/* Attempt to select our database */
/* If not able to select... */
if (!@mysql_select_db($dbName)) {
/* Return error information to Flash and quit! */
print "&list=" . urlencode("<b>Error:</b> Could not find $dbName database") . "&";
exit;
}
/* Fetch current time from server */
$currentTime = time();
/* Build SQL query to insert our information into table */
$query = "INSERT INTO $table (name, email, location, entryDate) ";
$query .= "VALUES('$name', '$email', '$location', $currentTime)";
/* Execute query */
$result = mysql_query($query);
/* If there was an error executing query... */
if (!$result) {
/* Return error information to Flash and quit! */
print "&list=" . urlencode("Error: Could not insert record into download log") . "&";
exit;
}
/* Build SQL query to fetch all entries from the table */
$query = "SELECT * FROM $table ORDER BY entryDate DESC";
/* Execute query */
$result = mysql_query($query);
/* If there was a problem with the query... */
if (!$result || @mysql_num_rows($result) < 1) {
/* Return error information to Flash and quit! */
print "&list=" . urlencode("No entries in table $table") . "&";
exit;
}
/* Reset variable to hold output */
$list = "";
/* For each table entry returned... */
while($row = mysql_fetch_array($result)) {
/* Create human readable date from timestamp */
$entryDate = strftime("%A %d/%m/%y", $row['entryDate']);
/* Add details to output variable */
$list .= "<b>Date:</b> " . $entryDate . "<br>";
$list .= "<b>Name:</b> " . $row['name'] . "<br>";
$list .= "<b>Email:</b> " . $row['email'] . "<br>";
$list .= "<b>Location:</b> " . $row['location'] . "<br><br>";
}
/* Output data in required format */
print "&list=" . urlencode($list) . "&";
/* Close link to MySQL */
mysql_close($link);
?>