To Lhasa to Leh!

Friday, March 11, 2005

script to send Variables to PHP

If any of you wantt o send a variable to a PHP file on the server then here are 2 scripts to do so:

There are two ways. Assuming you have a var called "myVar" and you are sending it to a PHP page called myphppage.php using POST,1) reccomended:

code:

var ldPHP=new LoadVars()
ldPHP.myVar="some value here"
ldPHP.onLoad=function(success){
if(success) {
trace("succesfully sent the varaible");
} else {
trace("failed to send the variable");
}
}
ldPHP.sendAndLoad("myphppage.php",ldPHP,"POST");

2)

code:
myVar="some value here"
loadVariables("myphppage.php",_root,"POST")


The LoadVars method is better as it tells you if the call has been succesful or not.In the PHP page, the variable can be accessed as if sent by a form submission

0 Comments:

Post a Comment

<< Home


 
d