Php-flash newb

Hello, i dont mean to be another one of those newbie pests asking another basic question that tends to bother the elders of the forum, but where other forums have let me down, im hoping kirupa can help :slight_smile: Heres my dilemma. I’ve been reading through tutorials, ive had other forums hit me with jargon i cant seem to comprehend, and im left alone, cold, and abused :hurt:. anyway. Simply enough all i want to do, is have an input box, a dynamic box, and a button. I type in the inputbox, i click the submit, i see in the dynamic. I understand the concept of load the variable into either a loadvariables, or loadVars, send that to my http://localhost/php.php file, use either $_POST, $_GET, etc. and have that print $variable here, back into flash using again, the loadVars, or loadVariables. Heres where i puzzle. In theory, i believe to know what to do and how to go about doing it, and when i go to work it out… no results. i downloade phpdev to setup the apache server … and the other things that came with it, and ive followed the tutorial on how to get a dynamic box to show a variable successfully, but when i branch off on my own im stuck. Heres what i got:

Actionscript:
this.submit.onPress = function() {
sender.loadVariables(“http://localhost/tests/php.php”, “POST”);
form.loadVariables(“http://localhost/tests/php.php”, “POST”);
};

sender is the movie clip that contains the inputbox
form is the movie clip that contains the dynamic box.

php:
<?
$text = $_POST[“sendthis”];
print “&read=$text”;
?>

sendthis is the variable name of the input box
read is the variable name of the dynamic box

Again i dont mean to be a bother, or sound obnoxious… its been a long frusterating time of trial and error. Prethanks for any help.

loadVariables is pretty unpredictable. I’ve always had better luck using the loadVars object.

ive tried using loadVars prior to loadVariables because i know that it is easier to retrieve the variables. ex: variable.var1, variable.var2, etc. However im still unable to send my variable from flash to the php. Ive been able to retrieve data from php back to flash. ex:

<?
$var1 = “hello world”;
print “&read=$var1”;
?>

using the method of loadVariables im able to retrieve no problem. Using loadVars however is another story. using loadVars i get "&read=hello%20World%20function()%20=onLoad, etc, a bunch of garbage. i believe that the %20 has something to do with HTML for i’ve seen it in browsers before. Im more focused right now on sending data to the php rather than getting it.

try doing it with POST instead of GET. The %20 is how a space is interpereted in a URL.

ok, skratch what i said before, im gonna try to make myself more clear, and simple in what im trying to accomplish.

All i have on the main timeline is a movieclip called submit
Actionscript (on frame):


this.submit.onPress = function() {
 sendme = new LoadVars();
 sendme = "One Small electronic data transfer for man, one giant headache for me";
 sendme.send("http://localhost/tests/php.php", "POST");
 trace(sendme);
};

and this is my php script:


<?
$text=$_POST['sendme'];
print $text;
?>

all i want to happen is for my http://localhost/tests/php.php, to say what my loadVars is. Once this happens, ill go from their, but for now its still nonfunctional and i dont understand why.

Has anyone else had the problem where this works :


myLoadVars.send("something.php","newWindow");

but this does not :


myLoadVars.send("something.php");

???

It’s like the PHP only recieves the variables if the window is opened, otherwise it just doesn’t work?

-EG


this.submit.onPress = function() {
 sendme = new LoadVars();
 sendme.quote = "One Small electronic data transfer for man, one giant headache for me";
tempsend = new LoadVars();
 tempsend.sendAndLoad("http://localhost/tests/php.php", sendme, POST);
 trace(sendme.quote);
};


<?
$text=$_POST['quote'];
echo "$text";
?>

That should work if I’m not mistaken. You had a few errors in your code. First of all, loadVars is an object. It can store more than one value. For this reason, you can not set your loadVars to one specific string. You must use it as you would use a movieclip, and put your seperate variables inside of it. Second, you can’t send the loadvars from inside itself, you must create a new loadvars to send it (at least i’ve always had to to get it to work). Also, for some reason it doesn’t work if you put quotes around POST.

In the php, you are trying to echo the specific variable. So you want to use quote, not the name of the entire loadvars.

Hope this helped :beer:

Grandpa: Use sendAndLoad to solve that problem (as I did above but didn’t mention…) You probably wanted it to open in a new window though when i look back… Oh well, that should be easy enough for you to change :wink:

Ok, thank you for the loadVars explanation. That makes more sence than my prior logic. Question is now, when i click my movie clip, my “php.php” which im running through the apache server on localhost, should display “One small electronic transfer for man, one giant headache for me” right? If so, its not doing it. It appears as if it is sending something for it occasionally triggers a firewall monitor which alerts me of programs accessing the internet. Progress… yet not perfection. Help is greatly appreciated though. Oh, one more thing, which i dont want to sound like a complete moron saying this so late… does it matter that im running win98? … everything seams functional i’m even being able to log into a mySQL database, so just wondering.

you might need to forward some ports or something, are you running php on your system? And do you have a web server installed? That’s not my strong suit though, sorry.

As I said earlier, to see the result, you need to change that code I posted a little bit so that it pops up a window. Or change the php to echo out stuff in a format that flash reads and then use sendAndLoad plus onLoad to echo it out in your flash movie.