PDA

View Full Version : sending variables to php


coatimundi
02-07-2001, 01:01 PM
I'm trying to send variables to a php page, but having no luck.
On a button I've got this script:
on (release) {
_root.getCountry("Algeria");
}
This is the function, on frame 1, main timeline:
function getCountry (country) {
getURL ("http://www.coatimundi.com/country.php", "_blank", "POST");
}
The php script is:
<?php
print($HTTP_POST_VARS['country']);
?>
I want a new browser window to pop up with the country name , in this case Algeria, printed across the top. It's not working...can you tell me why?

thanks,
coati

Jesse
02-07-2001, 01:19 PM
Prolly because your country var is just an interim var and not a global variable (since it's being defined only for that loop of that function) and hence it isn't being passed. or something like that.

You'd be better off using:

on (release) {
_root.getCountry("Algeria");
}

function getCountry (country) {
_root:country = country;
getURL ("http://www.coatimundi.com/country.php", "_blank", "POST");
}

Or soem such. This way you'll have avariable called 'country' on the mains tage when you call your PHP and it should definantly be posted. Try echoing your country var in your php to text if it's comming through also ( "echo $country;" should do the trick, within the body of the HTML).

Also note this quote from the PHP manual:
---------------------------------------------
HTTP_POST_VARS
An associative array of variables passed to the current script via the HTTP POST method. Only
available if variable tracking has been turned on via either the track_vars configuration directive
or the <?php_track_vars?> directive.
---------------------------------------------

So it sounds like your doing it a complicated way, why not just make your PHP:
<?php
echo $country;
?>

That should do the same and will work more often on more servers.

Cheers

Jesse

coatimundi
02-07-2001, 03:58 PM
It's working great, but...
how can I format the output of the echo command? I mean make it bold, change the font size, etc.

coati

coatimundi
02-07-2001, 04:06 PM
For anyone else who may have this problem, I just put the html commands outside the <?php ?> tags.

Thanks again,
coati