A Flash Developer Resource Site

Page 2 of 7 FirstFirst 123456 ... LastLast
Results 21 to 40 of 126

Thread: PHP not working?

  1. #21
    Senior Member
    Join Date
    Sep 2000
    Posts
    128
    thanks for the help but I'm going to have to leave the flash form off the site as I can't get any response other than 'unauthorised domain'.
    Shame that.

  2. #22
    Member
    Join Date
    Oct 2002
    Location
    Belgium
    Posts
    47
    I thought this was an easy thing to do, when you have the right software...
    In flash you create a form, naming all entree textboxes you want to send (assign 'var' values to them => 'sendto', 'subject', 'message' )
    When this is finished, create a button to send and to clear the form.
    I don't think I have to explain how to do this.

    Code for the Send button :
    Code:
    getURL("www.domain.com/sendmail.php", "_blank", "POST");
    Note : the sendmail.php file has to be on the same server as the flashmovie that contains the mailform. It won't work otherwise!

    code for sendmail.php :
    PHP Code:
    $sendto $_POST["sendto"];
    $subject $_POST["subject"];
    $message $_POST["message"];
    $send mail$sendto$subject$message)
    if(
    $send)
    {echo 
    "Your mail has been send succesfully";} 
    hope this helps a bit...
    --== A Flash N00B ==--
    http://www.avaweb.be

  3. #23
    Junior Member
    Join Date
    Jun 2003
    Posts
    22

    Getting vars from url into flash, then back into php

    Hi all,

    I'm having trouble understanding/implementing the use of vars in flash/php. I'm sucesfully loading dynamic text and jpegs from mysql using php. However, there's one piece that I can't figure out...any help is appreciated.

    What I want to do is pass a var to a page that contains my movie, such as www.site.com/index.php?id=4 - No prob so far.

    Then, I need my movie to pick up that var and pass it on to the script I'm using to load text from the db. Currently, my dyn text is coming from something like www.site.com/script.php - That script is looking for a var, but can't find it because flash hasn't sent it.

    I thought at first that it would pick up the variable sent in the URL, but it doesn't, because the URL I'm using to my script doesn't contain the var. How do I do this? How can I get that var (id=4) into the php script that loads my text?

    Here's the big pic if you want it. User comes to site, and uses an hmtl form to enter a code. That code ($id) is passed to the page that has the movie in it...and what I want it to do is serve up the text from the db record associated with the id used in the form. I'm missing something somewhere, and losing the var.

    Thanks for any help you can give...hope this makes sense
    Last edited by atsphpflash; 07-11-2003 at 05:21 PM.
    atsphpflash

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

    since the var is known before the flash is even loaded, you can use the
    <embed src="movie.swf?ID=3" ....>
    or
    <embed src="movie.swf" flashvars="ID=3" ...>
    method. The latter requires something like FP 6.0.50 ... so you should change that part in your html embedding

    Musicman

  5. #25
    Junior Member
    Join Date
    Jun 2003
    Posts
    22
    Musicman -

    I'm not sure if I understand your comments...the var isn't really known, because it comes from a form...the "id" could be anything that the user inputs. Am I missing your point?

    Would the code actually look like:
    <embed src="movie.swf?ID=$id" ....>

    Also - in my movie, what does the url to my script need to look like for my dyn content? If I just have: www.site.com/script.php - a var won't really be passed on to that script, will it? (even if the var is in the URL where the movie is embedded)

    Would the URL in my actionscript need to be something like:
    www.site.com/script.php?id=$id (I tried that, but it didn't work). I'm soooo confused.
    atsphpflash

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

    if I understood you right, you have some page that allows you to select an ID, and then loads a different page.
    This page shows a flash movie. So at the time the page is loaded, the ID is known (in contrast to situations where a form in one frame of a frameset changes content of another frame)
    You would need an echo or print in your php, either
    <?
    echo "<embed src=\"movie.swf?ID=$id\" ...>";
    ?>
    or
    <embed src="movie.swf?ID=<? echo $id; ?>" ....>

    In the movie, all you need to do is use the var

    Musicman

  7. #27
    Junior Member
    Join Date
    Jun 2003
    Posts
    22
    Hi,

    Thanks for your help...I'm doing a poor job explaining, so let me try again.

    HTML input form allows users to input a userid code.
    That form takes user to this link:
    http://www.url.net/vision_sites/temp...serid=pfleming

    (Where userid equals whatever their input was)

    On that page is a movie that loads dynamic text. The URL being used in the actionscript to get that text currently looks like this:
    http://www.url.net/vision_sites/content1_1.php

    BUT - I need it to look something like this:

    http://www.url.net/vision_sites/cont....php?userid=pf

    (where the 'pf' is automatically inserted based upon the variable used on the index.php page above).

    The script (content1_1.php) that gets text from db is looking for the variable $userid, so the first example returns nothing, because no var [$userid] is actually passed to it. If I 'hard code' the second example into my movie, I get the results I want. But, of course, I don't want to hard code it, because it is dependant upon user's input.

    So, how do I get my actionscript to pick up the variable [$userid] from index.php (above) and pass that on to my script at: content1_1.php? I thought something like this would work:

    http://www.url.net/vision_sites/content1_1.php?userid=$userid - but it doesn't

    The script in my php looks like this, if it matters:

    <?

    (snip)

    // formulate and execute query
    $query = "SELECT content1_1 FROM content1 WHERE userid='$userid'";
    $result = mysql_query($query) or die("Error in query: " .
    mysql_error());

    // get row
    $row = mysql_fetch_object($result);

    // print output as form-encoded data
    echo ($row->content1_1);

    (snip)

    ?>


    Clear as mud?? Thanks for your help
    Last edited by atsphpflash; 06-13-2009 at 01:57 PM.
    atsphpflash

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

    it is two steps
    - put the userid part into your index.php (both embed src=... and param name=movie parts). This will make a userid variable available to actionscript.
    Now the actionscript can call the content.php with the added variable.
    loadVariables('content.php?userid='+escape(userid) , ....)

    Musicman

  9. #29
    Junior Member
    Join Date
    Jun 2003
    Posts
    22

    Close....

    Hi,

    Well, I've embedded the movies as suggested, and I've modified the actionscript like this:

    loadVariablesNum("http://www.url.net/vision_sites/content1_1.php?userid="+escape(userid), 0, "GET");

    The php script referenced above looks like this:
    <?
    // Conects db to flash for dynamic content
    // open connection to database
    include("settings.inc.php");
    $connection = mysql_connect($hostname, $username, $password) or die
    ("Unable to connect!");
    mysql_select_db("$database") or die ("Unable to select database!");

    // formulate and execute query
    $query = "SELECT content1_1 FROM content1 WHERE userid='$userid'";
    $result = mysql_query($query) or die("Error in query: " .
    mysql_error());

    // get row
    $row = mysql_fetch_object($result);

    // print output as form-encoded data
    echo "content1_1=" . urlencode($row->content1_1);

    // close connection
    mysql_close($connection);
    ?>

    But - still nothing....
    The PHP code above works, and outputs this:

    content1_1=this+is+a+userid+test

    Which is what I want....it just won't show up in my movie...

    Your help is much appreciated....what is going wrong????
    Last edited by atsphpflash; 06-13-2009 at 01:56 PM.
    atsphpflash

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

    as far as I can see the loadvariables call happens inside a movieclip. You should use
    loadVariablesNum('content1_1.php?userid=' + _root.userid, 0)
    to get the correct variable. Also, there is no need to specify GET at that point; this just means that all vars in the current timeline are sent to the server (at the moment this is some <p align...></p> stuff from an empty html textfield)

    Musicman

  11. #31
    Junior Member
    Join Date
    Jul 2002
    Posts
    20
    I'm having problems passing variables from Flash to PHP from a flash movie that has to be displayed within a frame. The variables pass correctly when the movie is in a regular html page with no frames, but they don't get to the php page when the flash is within a frame. I've checked our server config and we have PHP 4.3.2. The problem seems to be specific to PHP because I'm able to send the variables to perl cgis.

    Any idea what is going on here?

    Here's the actionscript to pass the variables:
    on (release) {
    myData=new LoadVars();
    myData.Variable1="Flash";
    myData.Variable2="is";
    myData.Variable3="driving";
    myData.Variable4="me";
    myData.Variable5="crazy!";

    myData.send('ApplicationRatings.php','_blank', 'POST');
    _root.gotoAndPlay(2);
    }

    Here's the PHP I'm using to get the variables:

    if (empty($_POST)){
    print("there aren't any post variables");
    print("<P>");
    }
    print ("What is POST going on here:".$_POST["Answer1Text"]."<br/>");
    while (list ($key, $value) = each ($HTTP_POST_VARS) ) {
    print "key=".$key.":".$value."<br/>";
    }

    Thanks
    -Kim

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

    can you post a link to your page?

    Musicman

  13. #33
    Member
    Join Date
    Apr 2003
    Location
    North East, MD
    Posts
    62

    having same problem

    having trouble with a larger project, but when experimenting, even this simple example won't work..

    Here is my AS:
    ------------------------------
    var myvars = new LoadVars();

    myvars.name = "steve";
    myvars.dogs = "kilby and cayenne";
    myvars.number = 2;

    getURL("http://fakester.50free.net/test/savevars.php?"+myvars.toString());

    stop();

    ------------------this works fine, but:

    myvars.send("http://fakester.50free.net/test/savevars.php",GET);

    ------------------doesnt work.

    php script:

    <?

    $name = $_GET['name'];
    $dogs = $_GET['dogs'];
    $number = $_GET['number'];

    $fp = fopen("newfile.file", "a") or die("Couldn't create new file");

    $numbytes = fwrite($fp,"added this text to the file".$name.$dogs.$number);

    fclose($fp);

    echo("$numbytes written to text file");
    ?>

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

    the AS manual puts the GET into position three of the params, after url and a target frame

    Musicman

  15. #35
    I Like To Flash in Public ;) thebluedragon's Avatar
    Join Date
    Aug 2001
    Location
    London, U.K
    Posts
    194
    Hey ppl please help me with my php,

    goto the below thread!

    Its really annoying me! PLease help


    http://www.flashkit.com/board/showth...hreadid=507336

    Blue Dragon

  16. #36
    imagination through stupidity
    Join Date
    Apr 2001
    Location
    P3X-3113
    Posts
    1,238
    yea, i noticed this when i setup my new IIS 6.0 Local Server.
    Nothing to see here, move along.

  17. #37
    Senior Member
    Join Date
    Dec 2000
    Posts
    181
    Great info in this thread! However, it's not helping my situation:

    I just changed hosts, found my PHP mail forms no longer worked, came here and saw this thread. My new server is running PHP 4.3.3, so I assumed that was the problem. The weird thing is, register_globals is turned "on" on my server, and my scripts still won't receive my variables from Flash. I've tried several of the suggestions here, and it still doesn't work. The script sends me an email like it's supposed to, and prints a "success" message back to the Flash movie, but the email doesn't contain my variables!
    I just tried using the script via an html form, and it does work, so it's just from Flash. I'm using the absolute URL too, but that doesn't seem to help.

    Being a total PHP n00b, I'm a little stumped

    Anyone have any ideas?
    Last edited by NocturnalGuy; 12-19-2003 at 11:13 PM.

  18. #38
    Senior Member
    Join Date
    Dec 2000
    Posts
    181
    Follow-up: I realized that everything works fine in IE; I had been trying it in Opera. Weird. Now to figure that one out...

  19. #39
    Registered User
    Join Date
    Jan 2003
    Location
    england
    Posts
    131
    HI People have gravitated here because i too am on php 4.2.3 and the register_globals is indeed off and I dont have that 'H$$P'-whatever code on my script and as many of you have suffered I can see, I too am not getting any variables from my flash to the php and thus to my Database. I am presuming this means I wont be able to fish anything out of the Database via the php file using flash either.

    The flash just dont wanna talk to my php file!!!
    My php file works great without it!! so......

    Now i am a simple person.
    All I want is one method to get the vars out of flash and be seen by the php and visa-versa-vista-vusta etcc..

    I am using flash 5 so be kind.

    hope that someone can explain to me how I can get my vars to be picked up by the php file.

    thanks
    Shaf

  20. #40
    imagination through stupidity
    Join Date
    Apr 2001
    Location
    P3X-3113
    Posts
    1,238
    Originally posted by shafak cangil
    HI People have gravitated here because i too am on php 4.2.3 and the register_globals is indeed off and I dont have that 'H$$P'-whatever code on my script and as many of you have suffered I can see, I too am not getting any variables from my flash to the php and thus to my Database. I am presuming this means I wont be able to fish anything out of the Database via the php file using flash either.

    The flash just dont wanna talk to my php file!!!
    My php file works great without it!! so......

    Now i am a simple person.
    All I want is one method to get the vars out of flash and be seen by the php and visa-versa-vista-vusta etcc..

    I am using flash 5 so be kind.

    hope that someone can explain to me how I can get my vars to be picked up by the php file.

    thanks
    Shaf

    do

    getURL("www.mydomain.com/phppage.php?id=var1&id2=var2&blah=var3");

    the string has to be constructed first, but that is the basic idea.

    Then from php you can do HTTP_GET_VARS[var1] or whatever/
    Nothing to see here, move along.

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