# Retrieving variables from php

**URL:** <https://forum.kirupa.com/t/retrieving-variables-from-php/264081>\
**Category:** Uncategorized\
**Created:** [June 23, 2008, 1:30am UTC](https://forum.kirupa.com/t/retrieving-variables-from-php/264081 "2008-06-23T01:30:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lebonbon](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@lebonbon](https://forum.kirupa.com/u/lebonbon)\
**Post date:** [June 23, 2008, 1:30am UTC](https://forum.kirupa.com/t/retrieving-variables-from-php/264081/1 "2008-06-23T01:30:33Z")

</div>

okay, so i kinda understand how to POST to my php file from a flash-form  
but could someone give a quick example of the other way round,  
how to set up variables in a php-file and read them from an AS-file

sry, php-noob

thanks /bon

---

<div class="post-metadata">

**Author:** ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)\
**Post date:** [June 23, 2008, 8:39am UTC](https://forum.kirupa.com/t/retrieving-variables-from-php/264081/2 "2008-06-23T08:39:02Z")

</div>

send you name and message.  
history not forget this, since php file save all to text file.

```auto

//start code first frame //guest.fla
var url:String = "http://dnadillo.dn.ua/fla/js-swf-html/guest.php";
var request:URLRequest = new URLRequest(url);
var variables:URLVariables = new URLVariables();
            variables.exampleSessionId = new Date().getTime();
            variables.user_name = "";
            variables.user_message = "";
 
request.data = variables;
var loader:URLLoader = new URLLoader();
configureListeners(loader);
  try {
       loader.load(request);
      } 
  catch (error:Error) 
      {
      trace("Unable to load requested document.");
      }
 
 
function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
         }
 
 
function completeHandler(event:Event):void {
            var loader:URLLoader = URLLoader(event.target);
            trace("completeHandler: " + loader.data);
// trace("completeHandler: " + loader.data.GaleryScoresText);
            var vars:URLVariables = new URLVariables(loader.data);
            trace("The GaleryScoresText is " + vars.buff);
            my_out_txt.text=vars.buff+"

";
        }
 
 
var m_filter:Mur_filter = new Mur_filter();//&#1084;&#1086;&#1081; &#1082;&#1083;&#1072;&#1089;&#1089;//&#1085;&#1072; &#1089;&#1083;&#1077;&#1076;&#1091;&#1102;&#1097;&#1077;&#1081; &#1089;&#1090;&#1088;&#1086;&#1095;&#1082;&#1077; &#1090;&#1086;&#1078;&#1077;
var load_mc_button:Mur_filter_button = new Mur_filter_button(my_mc,m_filter,load_mc_function);
function load_mc_function()
{
 variables.exampleSessionId= new Date().getTime();
 variables.user_name = my_name_txt.text;
 variables.user_message = my_message_txt.text;
 my_name_txt.text="";
 my_message_txt.text="";
   try {
       loader.load(request);
      } 
  catch (error:Error) 
      {
      trace("Unable to load requested document.");
      }
}
//finish of code first frame        
 

```

PHP

```auto

<?php
$result_name=strip_tags($_GET['sessionId']);//chacker killer
$result_name=strip_tags($_GET['user_name']);//&#1093;&#1072;&#1082;&#1077;&#1088;&#1099; &#1083;&#1086;&#1084;&#1072;&#1090;&#1100; &#1076;&#1086;&#1083;&#1075;&#1086; &#1073;&#1091;&#1076;&#1091;&#1090;
$result_message=strip_tags($_GET['user_message']);//&#1093;&#1072;&#1082;&#1077;&#1088;&#1099; &#1083;&#1086;&#1084;&#1072;&#1090;&#1100; &#1076;&#1086;&#1083;&#1075;&#1086; &#1073;&#1091;&#1076;&#1091;&#1090;

//
$split_data=$result_name." <<".$result_message.">>
";
if (strlen($split_data)<10) $split_data="";
 if (filesize("guest.txt")<5000)//&#1077;&#1089;&#1083;&#1080; &#1073;&#1086;&#1083;&#1100;&#1096;&#1077; 5000 &#1073;&#1072;&#1081;&#1090;, &#1091;&#1076;&#1072;&#1083;&#1080;&#1090;&#1100; &#1074;&#1089;&#1077;
   {
   $fh=fopen("guest.txt","r");//
   while (!feof($fh)) //&#1087;&#1088;&#1086;&#1095;&#1080;&#1090;&#1072;&#1090;&#1100; &#1092;&#1072;&#1081;&#1083; (read file)
    {
    $buff.=fgets($fh);
    }
   fclose($fh);//close file
   }

$fh=fopen("guest.txt","w");
$split_data=$split_data.$buff;
if (strlen($split_data)>10) 
{
flock($fh,LOCK_EX);//&#1073;&#1083;&#1086;&#1082;&#1080;&#1088;&#1086;&#1074;&#1082;&#1072;
fwrite($fh,$split_data);//write file &#1077;&#1089;&#1083;&#1080; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077; &#1073;&#1086;&#1083;&#1100;&#1096;&#1077; 10 &#1073;&#1072;&#1081;&#1090;
flock($fh,LOCK_UN);//&#1088;&#1072;&#1079;&#1073;&#1083;&#1086;&#1082;&#1080;&#1088;&#1086;&#1074;&#1082;&#1072;
}
fclose($fh);//close file
echo "buff=".$split_data;

?>

```

[http://dnadillo.dn.ua/fla/js-swf-html/guest.swf](http://dnadillo.dn.ua/fla/js-swf-html/guest.swf)  
[http://dnadillo.dn.ua/fla/js-swf-html/guest.zip](http://dnadillo.dn.ua/fla/js-swf-html/guest.zip)  
[http://dnadillo.dn.ua/fla/js-swf-html/guest.txt](http://dnadillo.dn.ua/fla/js-swf-html/guest.txt)

---

<div class="post-metadata">

**Author:** ![lebonbon](https://avatars.discourse-cdn.com/v4/letter/l/eada6e/32.png) [@lebonbon](https://forum.kirupa.com/u/lebonbon)\
**Post date:** [June 24, 2008, 1:44am UTC](https://forum.kirupa.com/t/retrieving-variables-from-php/264081/3 "2008-06-24T01:44:17Z")

</div>

thanks man, much appreciated…

got everything working…very helpful

/s
