A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Checkbox on my flash/php site

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Posts
    13

    Checkbox on my flash/php site

    Hello people

    I have made this page http://www.aktivepost.no/stunt/phpform/phpform6.swf where i want to include several check boxes, the code on the check boxes is (only one there at the moment)

    Code:
     
    on (release) {
        af = this._currentframe;
        if (af%2) {
            _root.news = "No";
            _root.results = "News off!";
            gotoAndStop(2);
        } else {
            _root.news = "Yes";
            _root.results = "News on!";
            gotoAndStop(1);
        }
    }
    And i want to receive this variable $news in my PHP mail, but i stuck because i cant seem to put the correct code on the send button so that i get the check box result in the mail.

    Everything else is working on the form and mail, but the check box thing is a puzzle for me.

    Can any of you give me a hint in the right direction

    Cheers

    Retro...

  2. #2
    Member
    Join Date
    Dec 2003
    Posts
    58
    Have you tried the LoadVars-object? It sends variables to the server and it handles all the form-encoding as well:

    transmit = new LoadVars();
    transmit.news = whatever;
    transmit.send("evaluation.php");

    In the Php-script the value of "whatever" will become available as:

    $_POST['news']

    How simple is that?

  3. #3
    Junior Member
    Join Date
    Apr 2003
    Posts
    13
    Looks simple, but im not there yet, have to play around with the LoadVars-object before i can start making some sense of what you are saying ;-)

    Cheers

    Retro..

  4. #4
    Junior Member
    Join Date
    Apr 2003
    Posts
    13
    Ok, i have been trying for days to get this check box to work, but with no luck so today i trashed it and went over to using standard flash components.

    So this is what i did:

    Added Flash UI component, CheckBox
    Added label "Aktivepost"
    Added instance name "ins_aktivepost"

    Added this code to my send button:

    Code:
    	mytmpvar = ins_aktivepost.getvalue();
    if (mytmpvar == true) {
    myvar = ins_aktivepost.getLabel(); }
    else {
    delete myvar;
    Added $myvar to my phpmail code


    But guess what, still is not working everything else is working ok but i cant seem to send the check box code to my phpmail.

    What am i doing wrong??

    This is the site im working on right now: http://www.aktivepost.no/stunt/phpform/phpform11.swf

  5. #5
    Member
    Join Date
    Dec 2003
    Posts
    58
    Okay, your code is either weird, or you left out so much, that I don't get it.

    Here's a rewrite:

    PHP Code:
    php = new LoadVars();
    php.aktivepost box.getValue() ? 'yes' 'no';
    //...
    php.send("form.php","_POST"); 
    and:
    PHP Code:
    if (!isset($_POST['aktivepost']) or !in_array($aktivepost, array('yes','no'))) exit();
    $aktivepost$_POST['aktivepost'];
    mysql_query("insert into contacts (aktivepost) values ('$aktivepost')"); 
    Hope, that helps!

    Peter

  6. #6
    Junior Member
    Join Date
    Apr 2003
    Posts
    13
    ok!! i got it!!

    I found out where the error was, it was between the chair and the computer ;-)

    I checked my first excample one last time and found out that i had forgot to set the two variables

    news = "Yes";
    results = "News on!";

    in the main timeline of my flash file so the checkbox was not activated (unless i clicked two times on the checkbox ) and i was not able to get a response to my phpmail file.

    Cheers

    Retro....

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