Getting POST from Flash

Discussion in 'PHP' started by donteatchicken, May 19, 2008.

  1. #1
    Is there anything special involved when getting info from a flash script?

    For instance shouldn't this work?

    
    
    <?php
    
    $nm=$_POST['__name']; 
    $em=$_POST['__email']; 
    $ti=$_POST['__time']; 
    
    
    //Connection info
    
    $host = "XXXXX"; 
    $user = "XXXXX"; 
    $pass = "XXXXX"; 
    $database = "XXXXX";
    
    
    //Open database
    
    $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
    mysql_select_db($database, $linkID) or die("Could not find database.");
    
    mysql_query("INSERT INTO stats (name, email, time) VALUES('$nm', '$em', '$ti')") or die(mysql_error());  
    
    
    mysql_close($linkID);
    
    $host = "XXXXX"; 
    $user = "XXXXX"; 
    $pass = "XXXXX"; 
    $database = "XXXXX"; 
    
    $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
    mysql_select_db($database, $linkID) or die("Could not find database."); 
    
    $query = "SELECT * FROM stats ORDER BY time ASC limit 5"; 
    $result = mysql_query($query, $linkID) or die("Data not found."); 
    
    //$name = $row['name'];
    //	$email = $row['email'];
    //	$time = $row['time'];
    
     $num = mysql_num_rows($result);
     
    
     $file= fopen("stats.xml", "w");
    
     $_xml .="<xml>\r\n";
     while ($row = mysql_fetch_array($result)) {
    
    
     $_xml .="\t\t<player name='" . $row["name"] . "' " . "email='" . $row["email"] . "' " . "time='" . $row["time"] . "'/>\r\n";
    
    }
     $_xml .="</xml>";
     
     
     fwrite($file, $_xml);
     fclose($file);
      echo "XML has been written.  <a href=\"stats.xml\">view xml</a>";
      
      mysql_close($linkID);
    
    ?>
    
    
    Code (markup):
    I'm being told by the flash programmer that the script has to run without loading the page??????:confused:

    he also mention something about sendandload..
     
    donteatchicken, May 19, 2008 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Flash scripts will call the page just like any other language. You can chose if by POST or GET.

    The above should work, if the flash script is sending the data via POST.

    You can always test using ob_flush, print_r and mail to yourself.

    Peace,
     
    Barti1987, May 19, 2008 IP