开发者

sending php session variables to flash

开发者 https://www.devze.com 2023-01-14 07:09 出处:网络
i am currently working on highscore system with php,mysql and flash. everything is done except a few things. i am struck at sending registered users and and guest users to the flash file. since 2 days

i am currently working on highscore system with php,mysql and flash. everything is done except a few things. i am struck at sending registered users and and guest users to the flash file. since 2 days im working but no luck. actually what my problem is in my highscore system i have provided the score submission to both registered as well as to guest user. if guest registered user submits the score then with the registered u开发者_StackOverflowsername the score should be submitted. whereas if guest submits the score the guest name appears whatever the guest types. i have tried with sessions but im new to this session programming. can anyone provide a small kind of example. please see my code....

$game_name = $_POST['game_name'];
$_SESSION['gamename'] = $game_name;

if($_POST['game_submit_btn']==1){
      //query here to add
      if($_SESSION['loggedinuserid']!=''){
        $_SESSION['hs_username']=$_SESSION['loggedinuser'];
        $_SESSION['hs_uid']=$_SESSION['loggedinuserid'];
      }elseif(strlen($_SESSION['hs_username'])<2){
        //$_SESSION['hs_user_name']='guest'.rand(0,999);
        $_SESSION['hs_username'] = 'Guest User';
        $_SESSION['hs_uid']=0;
      }
  }

And also one more thing is after submission of highscore i have bookmarked the site and again i revisited the site but the highscore values are not diaplaying..why it s happening....please reply me soon....awaiting for response....


Here's a tutorial on how you can use the Zend Framework to communicate between Flash & PHP, this only addresses the last part of your question. http://gotoandlearn.com/play.php?id=90

You said you bookmarked the site but your site would have to first make a PHP call to retrieve the score values stored in mysql in order to display them. Values could be "cached" in a SharedObject but, just like a cookie, this would only work with the browser that was used in the first place.

Check the docs for the SharedObject: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/

Now the rest of your question, is more of a PHP question, so I leave this to more specialized people here, although , were you to decide to use Zend Amf ,the Zend Framework has some great tools for authentication & access control...

Edit: The point wasn't if you were using a framework or not , rather if you should use one.

I had a look at the site you mention in your comment... I was under the impression that you wanted to display the results in Flash, if not a simple MySQL query should do the trick... if you do , you can use Zend Amf or any other method you prefer to send the MySQL data to Flash.

0

精彩评论

暂无评论...
验证码 换一张
取 消