A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Flash-PHP-MySQL and back again?

  1. #1
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    Guys
    Here is my dilema.
    I have screensavers I am distributing but I wish the user to register. Here is how I think it should work.
    1. When saver is installed Flash looks for an .ini file on users pc. If not found it brings up a registration screen.User must be online to proceed.
    2. User enters details(2 variables) and then submits. Here is submit button code.
    loadVariables("http://path/reg.php", "_root.response", "GET");
    This should(according to Colin Moock of http://www.moock.org ) execute the script and send the response to the movieclip instance "response" back in flash. The php script checks the variables against our MySQL database to decide which response is returned.
    3. If correct response is received flash continues along and writes the .ini file to the users hard drive to avoid this sequence next time.
    4. If wrong response received an error message appears.

    It is as simple as that. I'm sure it can be done but there must be something I have overlooked. I have included the php script below. Please help if you can.


    Regards
    Scott Mayer

    <?php
    include("config.php");

    // Log Connection
    if (!$email){ $email = 'none'; }

    $mydate = date("F j, Y, g:i a");
    $host = $HTTP_ENV_VARS["REMOTE_ADDR"];
    $ordernum;
    $regkey;

    if (($ordernum)&&($regkey)) {
    header("Content-type: text/plain");

    // Check for a Purchase Record
    $result = mysql_query("SELECT * FROM ppurchases, products WHERE ppurchases.ordernum=\"$ordernum\" AND products.regkey=\"$regkey\"", $dbconn);
    $row = mysql_fetch_array($result);

    if ($row) {
    $sec = 'yes';
    } else {
    $sec = 'no';
    }

    $security = "&security=";
    $security .= rawurlencode($sec);
    echo $security;
    }

    $resultTwo = mysql_query("INSERT INTO accesslog (host,ordernum,regkey,email,accessdate) VALUES (\"$host\",\"$ordernum\",\"$regkey\",\"$email\",\" $mydate\");", $dbconn);
    ?>


  2. #2
    Senior Member
    Join Date
    Nov 2000
    Posts
    142
    I don't think it is actually possible to write to a file on someones computer via the standalone. I ran into a similar situation and tried using cookies, doesn't work unless you expect users to be always online and allowing cookies any time your screensaver is used.

  3. #3
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527
    I'm pleased to tell you it is possible. I now have the whole thing working properly as per my initial post. Thank God for forums.

    Scott

  4. #4
    Senior Member
    Join Date
    Nov 2000
    Posts
    142
    wow!, where did you find the solution? what was the solution? i gave up on the project after not finding any solution but would totally take it out of the cobwebs.

  5. #5
    Junior Member
    Join Date
    Dec 2000
    Posts
    18
    Might help if you explain the solution. So you were able to read/write to a local file? Or was another solution used?

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

    You can use SWF Studio (www.northcode.com) to read and write files from Flash.

    Download the FileSys example from http://www.northcode.com/free/ff2001 for an example.

    I also have a new plugin coming out this weekend that allows you to read and write INI files to better organize your data.


  7. #7
    mentally unstable member smayer72's Avatar
    Join Date
    Jan 2001
    Posts
    527

    Have not received emails, sorry

    Guys
    Sorry for not replying but I only just found this thread again. I did not get any emails when you posted. FK problems again. I achieved my success by the following.

    Frame 1
    loadVariablesNum ("file:///c|/windows/system/file.ini", 0);
    Frame 5
    If statement to check if my variable was loaded. If yes movie plays. If not takes user to registration screen.

    Reg Scene
    After user enters details and submits, PHP script checks data against a MySQL database and sends a response to a mc within flash. If data is incorrect. takes user to a failure screen. If successful allows movie to continue and executes this line of code.

    fscommand("save", "c:\\windows\\system\\file.ini");

    Thats all there is to it. Any other questions or more info needed just post me or email me.


    Scott(Australia)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center