PDA

View Full Version : Passing variables from flash to php


oatesj77
10-11-05, 06:56 PM
I've been stuck on this all day, I've mad a form in flash that should pass variables to a php script. I created 3 text boxes as text-input (name, email & content) and set the variable names as "name", "email" & "content"

the AS for my submit button was

on (release) {
loadVariablesNum("mail.php", "", "POST");
gotoAndStop (2);
}

this should pass all my variables to test.php, but I get nothing, I am using the same php script I have for my html form, same variables etc, placed side by side, the html works, but flash doesn't.

After messing with this for a few hours I decided to just see if the variables were coming through, created a file called test.php with the following:

<?php
$name=$_POST['name'];
$email=$_POST['email'];
$content=$_POST['content'];
?>
should output here:<br>
<? echo 'name: '.$name; ?> <br>
<? echo 'email address: '.$email; ?><br>
<? echo 'your message: '.$content; ?>


changed my flash submit to:

on (release) {
getURL("test.php", "", "POST");
gotoAndStop (2);
}

this should just pass the variables with POST to test.php where they would be displayed, but I get nothing, I tested with my html form to test.php and I get the variables displayed.

Can anyone help me out?

thanks

YvetteKuhns
10-12-05, 05:17 PM
http://codewalkers.com/tutorials.php?show=10
This tutorial walks you through the creation of a Flash form created using Flash version 5.

http://www.tutorialized.com/tutorials/PHP/Flash-and-PHP/1
more php and Flash tutorials

http://www.kirupa.com/developer/actionscript/flash_php_email.htm
php and flash form to email tutorial

I am not a fan of Flash forms since not everyone uses Flash. I haven't done this in a while, so I thought I would post examples for you.

oatesj77
10-12-05, 11:35 PM
Well, yeah, I read through that tutorial and several others, as far as I can tell, my flash is right, and so is my php, i just can't get the variable to pass from flash to php.

You know what the difference between loadVariablesNum and getURL, in either instance I don't see where you tell flash what variables to send, i'm guessing with loadVariablesNum, all the variables in the flash file get passed, but the page isn't opened, while getURL, passes & opens the page. either way I can't seem to figure where my problem is.

thanks

oatesj77
10-13-05, 03:36 AM
thanks yvette,
the tut from kirupa helped a lot. they basically grouped all the variables into a MC with an instance name, then appended the instance to the loadVarNum, eg... instance.loadVarNum("page.php", "POST"); i guess this groups all the variables up to be sent out, and that is where i was having the trouble.

okay, finally got it to send variables to a php script, but what i'm looking for is to pass variables to a php page and also go to that page where the variables can be utilized. I'm working up to adding dynamic data, but need to get a firm understanding of this simple stuff first.

i've been playing with getURL(), but that dokesn't seem to pass the variables.

any other ideas from you flash pros?