A Flash Developer Resource Site

Page 1 of 7 12345 ... LastLast
Results 1 to 20 of 126

Thread: PHP not working?

  1. #1
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044

    PHP not working?

    During spring, there was a major change in php's way to handle variables received from flash or html forms. This change was made to address some security concerns
    Before that time, variables from the form where simply available as php variables. The new php versions (4.1 or later) usually require you to pick up the vars from the form.
    Now, there are many scripts around that have not been adapted to the new servers. On the other side, there are also quite a few hosting companies still running php versions from two years ago.
    If your scripts fail to receive variables from your movies, please check
    a) what is the php version on the server: simply upload a file phpinfo.php with that one line
    <?php phpinfo(); ?>
    in it and open it in the browser. The output will reveal the php version. If the version is 4.1 or later OR if the register_globals is off (somewhere down the page), then check
    b) is the script suitable for new servers. If it was last modified before spring, probably not
    Otherwise check whether at least one of $HTTP_GET_VARS, $HTTP_POST_VARS,
    $_GET, $_POST or $_REQUEST occurs anywhere in your script. If not, your script has to be fixed.
    Note: if you are testing on your own server, you can change the register_globals just to get the script working. This is not recommended: since it is a security thing, your hosting company will set it differently so your script fails if you upload to the web.

    Musicman

  2. #2
    Actually if you isert the following:

    foreach($HTTP_GET_VARS as $name => $value) { $$name = $value;}
    foreach($HTTP_POST_VARS as $name => $value) { $$name = $value;}
    foreach($HTTP_COOKIE_VARS as $name => $value) { $$name = $value;}

    Your variables will all be imported into your PHP script from Flash.
    Jim Almeida
    http://www.atechcommunications.com
    http://www.nunrg-records.com

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    the change was made for, let's say, security reasons. It ensures that only vars get into your scripts that you expect, and not vars that anyone adds to the http request for malicious reasons.
    Those script of yours just gets the unsafe state back.
    May I suggest something like that instead:
    Code:
    $postvars = array("abc", "def", "ghi");
    foreach ($postvars as $var)
     if(isset($_POST[$var]))
       $$var = $_POST[$var];
    Musicman

  4. #4
    Member
    Join Date
    Feb 2003
    Location
    Calgary
    Posts
    49
    Thanks for starting this thread. I am new to php and I was screwing around for hours trying to figure out why my variables were not working.

    So all I would have to do is substitute your "abc", "def", "ghi", etc. for my variables that are coming from flash and the rest of the code will allow them to be useable in my php script?

    $_REQUEST['myvar'] works for my variables yet $_POST['myvar'] does not. I assume I can substitute $_POST['myvar'] for $_REQUEST['myvar']?

    Why does $_REQUEST work for me and $_POST not?

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    you are probably passing vars with the GET method (or tacking them onto the url)

    Musicman

  6. #6
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    Is there a place I can see the result of <?php phpinfo(); ?>

  7. #7

    Thanks

    Great info musicman

    It helped me a lot with my work and I wish I has read it earlyer this day before I post my question )

    Keep up the great work.


    Stratos
    Lightform - Evolution One

    http://lightform.onar.gr

    Ex - Reactor 5.0

  8. #8
    The new php versions (4.1 or later) usually require you to pick up the vars from the form.
    May i have an simple example how am i going to do so? My script work with php 4.0.5. How do i get about in going to edit my script for it to work with newer php?

    Some sample of my currently script:
    Code:
    $query = "INSERT INTO $tablename (date, firstName) VALUES (now(), '$jFirstName2')";
    In this case, the jFirstName2 in Flash is being send to php as $jFirstName2. But now it seem not be the case, what else sld i do to solve this issue?

    Thanks
    chup

  9. #9
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    The most easy way will be if the server-administrater change
    "register_globals" to "on" in the php.ini file,
    followed by a restart of the webserver.
    Then nothing has to be changed.
    However the server may become easier vulnerable in future bugs.

  10. #10
    What happen if i have totally no control over the server?

  11. #11
    Senior Member unicycle's Avatar
    Join Date
    Mar 2000
    Posts
    254
    ask the one who does, tell him your problem, and that the cure is easy.

  12. #12
    No, i mean, if i dunwanna do anything to the server, is the any other solution i can work with? Like what is the new "correct" way to make this work?

  13. #13
    Member
    Join Date
    Dec 2002
    Posts
    62
    i don't know if i kept track of this conversation, but here is some help.. (Someone mentioned the fact that they needed help knowing how to correct their code...)

    Code:
    $_GET['name'];  //this would get a variable called "name" that was in the query string (address bar) or from a method="get" 
       // for example  user_setup.php?name=rob      "rob" would be returned..
    
    $_POST['name'];  //this would get a variable called "name" that was posted from a form with  method="post" in the <form> tag.

    Hope this helps a bit...

    (the code above has no Flash functions.. only php, so i don't know if it helps at all :P)
    there are two things that make true happiness!

    Love and Actionscript!

  14. #14
    Senior Member
    Join Date
    Sep 2000
    Posts
    128

    help!

    Hello, I've tried pasting in this code:

    $postvars = array("abc", "def", "ghi");
    foreach ($postvars as $var)
    if(isset($_POST[$var]))
    $$var = $_POST[$var];

    ...into my formmail script, replacing "abc", "def", "ghi" with "recipient", "subject", "content"

    Unfortunately this does'nt seem to have worked. Have I implemented it right? I just put it into the scriptunder the header. The script still works for the html forms on my site, but not for the flash.

    The script I'm using is the one available from http://www.dtheatre.com/scripts/

    Any help would be much appreciated. I know nothing about php by the way.

  15. #15
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    if it works with html but not with flash, maybe your movie is not really sending...
    Could you post url to the movie?

    Musicman

  16. #16
    Senior Member
    Join Date
    Sep 2000
    Posts
    128
    ok, I've put up a test version so you can see the response I'm getting:

    http://www.planetkoala.com/atest5.html

    It looks like it's calling the script but I've got some kind of security issue?

    Here's the script working in html:
    http://www.planetkoala.com/community.htm

    Cheers

  17. #17
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    your movie is not sending any data back to the server, but only requesting the php ... at least if you use FP6. It works fine with FP5, however.

    According to info I got from Macromedia when I reorted a similar problem, your movie should work if you use an absolute url rather than a relative one.
    The change was made sometime around 6.0.59 or 6.0.60, for no obvious reason. From the point of view of a normal user, I would consider it an outright bug: there is nothing in the documentation about it; it prevents reusing the same movie on similar systems; it breaks compatibility with existing movies created with older flash versions

    Musicman

  18. #18
    Senior Member
    Join Date
    Sep 2000
    Posts
    128
    Ah yeah crap bug. thankyou very much anyway, you're a lifesaver!

  19. #19
    Senior Member
    Join Date
    Sep 2000
    Posts
    128
    gah, I spoke too soon there, I've tried the full http:// address and just prefixing it with a "/" neither of these work
    (www.planetkoala.com/atest6.html and www.planetkoala.com/atest7.html respectively).
    any other ideas?

  20. #20
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    #6 works for me on both fp5 and fp6, #7 again only works on fp5

    Musicman

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