PDA

View Full Version : Flash Form to PHP to MySQL, Getting No Response



darley
June 14th, 2005, 12:16 AM
alright i have 3 pieces of code.

1) is the flash code for the form
this is in a MC, that is on a timeline comprises a movie that is being called from another movie. is that as confusing as it sounds?
2) is the contact.php code
3) is the displayResults.php code

i have double checked the labels and the spellings as well as the names of clips. i have been staring at this too long now...any help is appreciated.

1) The Actionscript---


submitBtn.onPress = function() {
if(strFirstName.text!="" && strLastName.text!="" && strEmail.text!="" && strAddress.text!="" && strCity.text!="" && strState.text!="" && strZipCode.text!="" && strSubject.text!="" && strMessage.text!=""){
myData = new LoadVars();
myData.strFirstName = strFirstName.text;
myData.strLastName = strLastName.text;
myData.strEmail = strEmail.text;
myData.strAddress = strAddress.text;
myData.strCity = strCity.text;
myData.strState = strState.text;
myData.strZipCode = strZipCode.text;
myData.strSubject = strSubject.text;
myData.strMessage = strMessage.text;
myData.sendAndLoad("contact.php", myData, "POST");
statusBox.text = "Thank You!";
myData.onLoad = function() {
trace(myData.strFirstName+myData.strLastName+myDat a.strEmail+myData.strAddress+myData.strCity+myData .strState+myData.strZipCode+myData.strSubject+myDa ta.strMessage);
}
strFirstName.text = "";
strLastName.text = "";
strEmail.text = "";
strAddress.text = "";
strCity.text = "";
strState.text = "";
strZipCode.text = "";
strSubject.text = "";
strMessage.text = "";
}else{
statusBox.text = "Fill out all required fields!";
}
}


2) The contact.php page


<?php
$userFirstName = $_POST['strFirstName'];
$userLastName = $_POST['strLastName'];
$userEmail = $_POST['strEmail'];
$userAddress = $_POST['strAddress'];
$userCity = $_POST['strCity'];
$userState = $_POST['strState'];
$userZipCode = $_POST['strZipCode'];
$userSubject = $_POST['strSubject'];
$userMessage = $_POST['strMessage'];

$conn = mysql_connect("hostingServer", "userName", "password");
mysql_select_db ("dataBaseName", $conn);
$result = mysql_query("INSERT into contacts (FirstName, LastName, Email, Address, City, State, ZipCode, Subject, Message) values ('$userFirstName', '$userLastName', '$userEmail', '$userAddress', '$userCity', '$userState', '$userZipCode', '$userSubject', '$userMessage');

?>



and finally 3) The code to display the results form the DB


<body>
<table width="75%" align="center">
<tr class="row"><td>First Name</td><td>Last Name</td><td>Email</td><td>Address</td><td>City</td><td>State</td><td>Zip Code</td><td>Message</td></tr>
<?php
$connection = mysql_connect("hostingServer", "userName", "password") or die("Error connecting to database");
mysql_select_db("dataBaseName", $connection);
$result = mysql_query("SELECT * FROM contacts ORDER BY id", $connection) or die("error querying database");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){
?>
<tr <?php if($i%2 == 1){ echo "class='body2'"; }else{echo "class='body1'";}?>>
<td>
<?php echo $result_ar['FirstName']; ?></td>
<td>
<?php echo $result_ar['LastName']; ?>
</td>
<td>
<?php echo $result_ar['Email']; ?>
</td>
<td>
<?php echo $result_ar['Address']; ?>
</td>
<td>
<?php echo $result_ar['City']; ?>
</td>
<td>
<?php echo $result_ar['State']; ?>
</td>
<td>
<?php echo $result_ar['ZipCode']; ?>
</td>
<td>
<?php echo $result_ar['Message']; ?>
</td>
</tr>
<?php
$i+=1;
}
?>
</table>
</body>

Thanks Again!

abcdefg
June 14th, 2005, 12:54 AM
Whats doesn't work? I don't see any errors off hand, only thing is why do you have those [i] in your connection string? I'm taking it that you did that just for the post.

Do the variables trace from Flash? Have you tryed using .send and printing the variables and or SQL statement and making sure everything is being passed?

darley
June 14th, 2005, 01:04 AM
Yes, I placed the [I] in there to make some of that code italic. Didn't work.

Anyway. Yes, the variables trace in Flash. It also loads the correct response in the 'statusBox'. But only when I run the SWF locally inside Flash.

I try and put it on my server and no go. So that is making me think there is something being goofy with my code once I get it up on the server.

I just wondered if their was anything that looked wrong with the code.
It seems like it should work.

darley
June 14th, 2005, 02:49 AM
Alright, well I went and put stuff into the DB itself, straight from PHP admin and it showed up on my results page. Does anyone have a quick piece of PHP form code that I could use to insert from a PHP page and see if that is the problem?

darley
June 14th, 2005, 03:02 AM
Okay so now I made a PHP form and submitted it and it worked. So I have broken the problem down to my other PHP page that is handling the submission data from the Flash movie itself. That is the contact.php that I showed earlier (#2 in the examples).

Is there a problem with this setup?
I have a main movie that loads external movies into itself in a placeholder on the main timeline. One of the external movies (contact.swf) is the one that contains the code for the form. Could the movie being nested like that cause a problem?

darley
June 14th, 2005, 12:33 PM
I went ahead and rebuilt the SWF itself. Made the submission work. But now I have another problem. I had built the form with INPUT TEXT AREAs and applying variables to them. With the new build I decided to use the TextInput Component. Just wanted a more uniform look. Well, now when I run the SWF by itself on the server the form works fine. But... the problem is I need the movie to load inside another movie. When I do that the TextInputs are not selectable and I cannot type into them. Any ideas on that one?

On the stage I have the 3 following components:
TextArea, TextInput and Button

I did a search about problems with that component, found some information, but no real solution.

Thanks!