Having trouble collecting posted data from .swf
I've been trying to make a few of the games I've made be able to submit scores to my website. To do this, the games are being displayed as .swf on respective pages with form html around them and a submit button below. (from web development, I've learnt that a form needs to be submitted rather than just linked to a page in order to pass post/get data).
Inside this .swf file the values are submitted as post data by the GET tool. I then have the submit button linked to a php page which utilises all of the posted data from before as well as cookies for usernames etc. however, it appears that the post data is not being collected from the .swf file.
I looked around these forums for a similar problem and found a similar thread, which was answered with using FlashVar parameters, which I have added but still been unsuccessful with.
Does anybody know where I'm going wrong?
[font:Courier New]<form action="arcade-score.php" method="post">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="JSFunction" width="640" height="480"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="../games/meteor.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="allowScriptAccess" value="sameDomain" />
<param name=FlashVars VALUE="param1=Gameid¶m2=Score">
<embed src="../games/meteor.swf" quality="high" bgcolor="#000033"
width="640" height="480" name="JSFunction" align="middle"
FlashVars="param1=Gameid¶m2=Score"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object><br>
<?php include("inc34b.php"); ?>
</form>[/font]
This is the html for the embedded .swf file.The php include file below simply links to a bunch of displaying of information and html which is not relevant to the .swf file. I'm not entirely sure how post data works with .swf. I thought that a form would be needed because from previous web development, I have used forms to cover inputs that are being used as post data.
The two Values being posted are 'Gameid' and 'Scores'.
All I want it to do is successfully....
- Post the data from the .swf file.
- This to be collected in the webpage.
- Collect this data successfully and then store it as a php variable.
Any information on how this POST works is also much appreciated. I assume it appears on the next page linked from the current page similar to POST forms.
Re: Having trouble collecting posted data from .swf
You don't need a form around the swf, forms are for doing posts from html.
Re: Having trouble collecting posted data from .swf
How would you use two post data's set from a .swf file on a webpage and then put these into php variables.
I'm not really sure how they work at the moment.
Re: Having trouble collecting posted data from .swf
Well, once a page has been loaded, you don't put anything else in to PHP variables, as the PHP is all processed on the server side - it just generates the page sent to the browser.
The FlashVars are for passing data into the game when a page has loaded, but you seem to be trying to put the game and score into the FlashVars.
Can you describe again what you're trying to do, without using any technical terms? I think what you're asking is quite simple to do, just that you're confused as to how you need to do it.
Re: Having trouble collecting posted data from .swf
I want to be able to POST the two values from the game (which are the score and gameid) and then retrieve these values on another webpage (which is linked to from the page containing my .swf game). The .swf file is displayed on one webpage so I assume that another web page will need to be linked to, in order to contain the post data as well.
The page afterwards collecting these values sent from the game basically has this at the top which sets these up as php variables:
$score=$_POST['Score'];
And then I know how to use it from there. I'm just a bit pickled about how to get these values that are being added as post data so they can be collected and changed to php values on the next page.
Re: Having trouble collecting posted data from .swf
The submit button should be in the game itself, which triggers the GET object to send data to a url such as 'arcade-score.php?score=9001'
The arcade-score.php then collects the value. (you won't see it happen in your browser, like your expecting from a normal php website. The game itself carries out this action. Think of the .swf as a mini-web-browser without an interface) then your acrade-score.php inserts it as a record in the database using mySQL functions your probably familiar with.
Finally, a 'view scores' link on your website reads from the database and sorts the scores from highest to lowest.
Re: Having trouble collecting posted data from .swf
Is there any available tutorials in relation to this? I previously used a tutorial involving the get url part of the get tool but that ended up in it never being able to connect to my server for some reason. Instead I figured it'd be easier to just put the values as Post Data and read them off on the next page.
I'm unable to select a php source for the POST value to be used on.
Re: Having trouble collecting posted data from .swf
Clickteam Tutorials
Scroll down to Online Scores using PHP/mySQL