PDA

View Full Version : Flash/PHP not working when uploaded....



artistwantab
06-16-2006, 02:59 PM
I have a very basic flash contact form that works perfectly locally. However when uploaded to my server it does not. The strange thing is I always had flash recover the PHP file from the remote server.

Any Help would be great...



senderLoad.sendAndLoad("http://eliocamacho.com/newSite/php/send.php",receiveLoad,"POST");

Here is the flash script

stop();
var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();
sender.onRelease = function() {
senderLoad.theName = theName.text;
senderLoad.theEmail = theEmail.text;
senderLoad.theMessage = theMessage.text;
senderLoad.sendAndLoad("http://eliocamacho.com/newSite/php/send.php",receiveLoad,"POST");
}
receiveLoad.onLoad = function() {
if(this.sentOk) {
_root.gotoAndStop("success");
}
else {
_root.gotoAndStop("failed");
}
}

Here is the PHP script

<?PHP
$theName = $_POST["theName"];
$theEmail = $_POST["theEmail"];
$theMessage = $_POST["theMessage"];

$to = "info@eliocamacho.com";
$subject = "Contact from webSite";
$message = "Name: " . $theName;
$message .= "\nEmail: " . $theEmail;
$message .= "\n\nMessage: " . $theMessage;
$headers = "From: $theEmail";
$headers .= "\nReply-To: $theEmail";
$remIP = getenv('REMOTE_ADDR');

$sentOk = mail($to,$subject,$message,$headers);

echo "sentOk=" . $sentOk;

?>

dvessel
06-16-2006, 05:35 PM
I most likely won't be able to help but your post is missing the other half...

The error. What's it doing? What kind of error?

artistwantab
06-16-2006, 05:56 PM
What do you me the other half.

That is all the code I have.

No error just fails to send. Send perfectly locally.

page1ink.
06-16-2006, 06:09 PM
have you tried using a relative path? as in, if the .swf file is in "http://www.blah.com/blah/blah2/contact.swf" set it to grab the php file from "./contact.php"

just throwing out there, I've not experienced this kind of problem before.

something to note is there may be some caching issues that are preventing the flash file from nabbing the contact.php correctly. download the web developer toolbar for FireFox and turn of caching, then try it again.

hope this helps!

dvessel
06-16-2006, 06:24 PM
I'm trying to learn php.. And I think I see what it is..

This last line isn't getting the mail function to execute. Have no idea how it's working on your test machine though.


$sentOk = mail($to,$subject,$message,$headers);
echo "sentOk=" . $sentOk;

this bypasses the temporary variable.


echo "sentOK=".mail($to,$subject,$message,$headers);

artistwantab
06-16-2006, 09:24 PM
I'm trying to learn php.. And I think I see what it is..

This last line isn't getting the mail function to execute. Have no idea how it's working on your test machine though.


$sentOk = mail($to,$subject,$message,$headers);
echo "sentOk=" . $sentOk;

this bypasses the temporary variable.


echo "sentOK=".mail($to,$subject,$message,$headers);


Well when I change that it stops working locally as well as remotely.

artistwantab
06-16-2006, 09:31 PM
have you tried using a relative path? as in, if the .swf file is in "http://www.blah.com/blah/blah2/contact.swf" set it to grab the php file from "./contact.php"


You nailed it...Thank you

page1ink.
06-16-2006, 11:29 PM
you're welcome =D

with silly problems like that it's always good to check the simplest things you can think of first, because those are the most overlooked. and then sometimes you just get sick of looking at your own code and need someone to bop you on the head hehe =)

anyway, glad I could help!

dvessel
06-17-2006, 07:43 AM
Well when I change that it stops working locally as well as remotely.

My bad.. :p I'm still getting the hang of things. Worked on my test machine.. The mail() part. :confused:

edsetsco
12-04-2006, 06:12 PM
Ok, it's almost shameful that I'm having trouble with this, but here goes...

I have

helloWorld.php
<?php
echo "myVariable=Hello World";
?>

And this Flash 8 file with this text in the first and only frame, it's published to root of my site with other PHP progs that run fine, and the helloWorld.php is in same directory as the Flash SWF and HTML page.

Here's the code from Flash

/////////////////
this.createTextField("display_txt",1,0,0,100,20);
var hello_lv:LoadVars = new LoadVars();
hello_lv.onLoad = function(success){
if(success){
display_text.text = this.myVariable;
}else{
trace("An error happened");
}
}
hello_lv.load("./helloWorld.php");
//also tried ("http://edsets.com/helloWorld.php");
/////////////////

That's it. Seems simple! I know my site works for PHP, it's edsets.com and the whole thing runs on PHP files. Other small test files work, as does 'http://edsets.com/helloWorld.php'

What happens when I publish the swf and html file from Flash 8 is that the page loads (I put a gray rectangle and a text block on the layer to make sure it's really there), but the Firefox status bar shows "Transferring data from edsets.com..." for a LONG time and nothing happens. I really have tried absolute and relative addressing, that doesn't seem to help.

Thx in advance for any ideas, folks,

Ed

Basil
12-04-2006, 06:52 PM
I don't deal with flash, but shouldn't you be loading the file before calling a variable from it?
Why do you have "hello_lv.load("./helloWorld.php")" as the last line in your code?
Seems like it should be right under "var hello_lv:LoadVars = new LoadVars()".

Pethens
12-04-2006, 07:27 PM
The Adobe documents say your loadvars have to be in application/x-www-urlform-encoded form. Try this for your PHP script:

<?php

header ("Content-type: application/x-www-urlform-encoded");
echo "myVariable=Hello World";

?>

I think that's part of the problem but I can't say for sure if it's the whole problem without looking at your code more closely.

Details here:
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary431.html


Stephen

edsetsco
12-05-2006, 03:29 PM
I must be having some kind of server problem or something. None of the well considered suggestions have worked. I can set the text manually in code:

display_txt.text = "Text!";

Which works fine, meaning that at least I know the flash movie is loaded on the server and the code is executing.

I am unable to get the trace() funciton to even run inside the 'if(success)' code however.

Thots?

Ed

FLASH CODE (ALL OF IT)
stop();
//Create a text field
this.createTextField("display_txt",1,50,50,100,20);
display_txt.autoSize = "left";
display_txt.border = true;

//The LoadVars object for loading the data
hello_lv = new LoadVars();

//the load was placed here and below also, same issue all times
hello_lv.load(" http://edsets.com/helloWorld.php ");

//When the LoadVars object receives the data
hello_lv.onLoad = function(success){
if(success){
trace("vars loaded");
display_txt.text = this.myVariable;
}else{
trace("An error happened");
}
}
//load the PHP

//display_txt.text = "Text!";



PHP FILE (which runs fine at http://edsets.com/helloWorld.php)

<?php
echo "myVariable=Hello World";
?>

edsetsco
12-05-2006, 05:16 PM
I remember Fortran and Punched Cards being easier in 1968 to get my first program running!

Here's the final successful run:

This PHP code produces this in Firefox: "myVariable%3DHello%20World" wihtout the quotes when called by "http://edsets.com/helloWorld.php"
-------------------------
<?php
header ("Content-type: application/x-www-urlform-encoded");
echo "myVariable=Hello World";
?>
-------------------------

Ok, that works.

The Flash program looks like this now (doesn't seem to matter where the "load" takes place, right after the definition, or below the 'onload' section, same result.
---------------------------
//Create a text field & make it visible even when empty
this.createTextField("display_txt",1,50,50,100,20);
display_txt.autoSize = "left";
display_txt.border = true;
//The LoadVars object for loading the data
var hello_lv:LoadVars = new LoadVars();
//When the LoadVars object receives the data, put it in the text field
hello_lv.onLoad = function(bSuccess:Boolean):Void{
if(bSuccess){
trace(this.myVariable);
display_txt.text = this.myVariable;
}else{
trace("An error happened");
}
}
//load the PHP
hello_lv.load("http://edsets.com/helloWorld.php");
---------------------------
Success finally. Thanks for the URL encoding tips. I'm not sure why that wasn't obvious to me other than I hadn't done this before and it never occured to me that the http response coming back from the server had to look like an http response and not just a text stream! The loadvars automatically escapes the string as needed!

Ed

Pethens
12-05-2006, 07:19 PM
Glad you got it working. As far as trace() is concerned, I don't think it does anything when running in a browser. I have been doing this instead:


getURL("javascript:alert('Hello World!');");

Regards,

Stephen