Page 1 of 1

Using post of get

Posted: Fri Apr 30, 2010 6:56 pm
by nick2price
Hi. I am a bit confused. I am trying to send a variable from php to as3, but dont know how to assign it in php. My HTML is simple

Code: Select all

 <html> 
 <head><title>Test Page</title></head> 
 <body> 
 <h2>Data Collection</h2><p> 
<form action="getName.php" method="post">
 <p>Your name: 
  <input type="text" name="name" /></p>
 <p><input type="submit" /></p>
</form>

 </body> 
 </html>
It is the name variable I want sent. In my php, I am doing

Code: Select all

<param name="FlashVars" value="myVar=<?php "$name" ?>" />	
It is the value part I am having issues with. I dont know if I need to use post or get to assign it to myVar, or how I can even do this,

Any help appreciated.

cheers

Re: Using post of get

Posted: Fri Apr 30, 2010 11:54 pm
by califdon
Your form specifies the method as POST, so you must retrieve the value from the $_POST environment array in the second PHP script.

Then, when you use it embedded in HTML, you have to echo it.

Code: Select all

<?php 
...
$name = $_POST['name'];
...
?>
...
<param name="FlashVars" value="myVar='<?php echo $name;  ?>'" /> 

Re: Using post of get

Posted: Sun May 02, 2010 5:26 am
by hypedupdawg
When you are assigning the value in your form, you are putting it in direct quotes. this will make the value literally "$name" rather than the variable $name. To do this you need to say

Code: Select all

<param name="FlashVars" value="myVar=<?php print $name; ?>" /> 
//or
<param name="FlashVars" value="myVar=<?php echo $name; ?>" /> 
You then pick the variable up as califdon said, using the $_POST method.

Re: Using post of get

Posted: Sun May 02, 2010 10:54 am
by califdon
Note: you can use echo or print interchangeably.