PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Coding a guestbook in AS2, doesn't work
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Coding a guestbook in AS2, doesn't work

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    9

    Coding a guestbook in AS2, doesn't work

    So I have been trying to make a "guestbook" kinda thing, but it doesn't seem to have any effect when I uploaded it to my server, nothing happens.

    Is there anything I'm missing here?:

    The following is my PHP file:

    <?php

    $naam = $_GET['naam'];
    $email = $_GET['email'];
    $msg = $_GET['msg'];
    $naam = ereg_replace("[^A-Za-z0-9 ]", "", $naam);
    $email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $email);
    $msg = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $msg);

    $comments = eregi_replace('******', '****',$comments);
    $comments = eregi_replace('kankerboeren', '****',$comments);
    $comments = eregi_replace('terin', '****',$comments);
    $comments = eregi_replace('kanker', '****',$comments);
    $comments = eregi_replace('vagina', '****',$comments);
    $comments = eregi_replace('tievus', '****',$comments);
    $comments = eregi_replace('*****', '****',$comments);
    $comments = eregi_replace('*****', '****',$comments);
    $comments = eregi_replace('pik', '****',$comments);
    $comments = eregi_replace('***', '****',$comments);
    $comments = eregi_replace('lul', '****',$comments);
    $comments = eregi_replace('god********', '@#%&^!#@!',$comments);
    $comments = eregi_replace('homo', '****',$comments);
    $comments = eregi_replace('flikker', '****',$comments);
    $comments = eregi_replace('nicht', '****',$comments);
    $comments = eregi_replace('hoer', '****',$comments);
    $comments = eregi_replace('likker', '****',$comments);
    $comments = eregi_replace('suck', '****',$comments);
    $comments = eregi_replace('****', '****',$comments);
    $comments = eregi_replace('slet', '****',$comments);
    $comments = eregi_replace('aids', '****',$comments);
    $comments = eregi_replace('nigt', '****',$comments);
    $comments = eregi_replace('******', '****',$comments);
    $comments = eregi_replace('****', 'poep',$comments);
    $comments = eregi_replace('neuke', '****',$comments);
    $comments = eregi_replace('boeren', '****',$comments);
    $comments = eregi_replace('hoeren', '****',$comments);
    $comments = eregi_replace('nicht', '****',$comments);
    $comments = eregi_replace('penis', '****',$comments);
    $comments = eregi_replace('p1is', '****',$comments);
    $comments = eregi_replace('boer', '****',$comments);
    $comments = eregi_replace('***wijf', '****',$comments);
    $comments = eregi_replace('doos', 'lekker wijf',$comments);
    $comments = eregi_replace('pisnicht', '****',$comments);

    $naam = stripslashes($naam);
    $email = stripslashes($email);
    $msg = stripslashes($msg);

    if ($Submit == 1) {

    $filename = "GuestBook.txt";

    // Opens up the file declared above for reading

    $fp = fopen( $filename,"r");
    $OldData = fread($fp, 80000);
    fclose( $fp );

    // Gets the current Date of when the entry was submitted
    $Today = (date ("l dS of F Y ( h:i:s A )",time()));

    // Puts the recently added data into html format that can be read into the Flash Movie.
    // You can change this up and add additional html formating to this area. For a complete listing of all html tags
    // you can use in flash - visit: http://www.macromedia.com/support/fl...s/htmltext.htm

    $Input = "Name: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></u></b><br>Website: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u></b><br>Comments: <b>$Comments</b><br><i><font size=\"-1\">Date: $Today</font><br><br>.:::.";

    /* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file */

    $New = "$Input$OldData";

    // Opens and writes the file.

    $fp = fopen( $filename,"w");
    if(!$fp) die("&posts=cannot write $filename ......&");
    fwrite($fp, $New, 800000);
    fclose( $fp );
    }

    // ################################################## #################################
    // ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##



    // Next line tells the script which Text file to open.
    $filename = "GuestBook.txt";

    // Opens up the file declared above for reading

    $fp = fopen( $filename,"r");
    $Data = fread($fp, 800000);
    fclose( $fp );

    // Splits the Old data into an array anytime it finds the pattern .:::.
    $DataArray = split (".:::.", $Data);

    // Counts the Number of entries in the GuestBook
    $NumEntries = count($DataArray) - 1;

    print "&total=$NumEntries&start=$NumLow&end=$NumHigh&pos ts=";
    for ($n = $NumLow; $n < $NumHigh; $n++) {
    print $DataArray[$n];
    if (!$DataArray[$n]) {
    Print "<br><br><b>No More entries</b>&";
    exit;
    }
    }
    ?>
    The next piece of AS2 scripting is located on a visual empty frame on the same height level as the input fields:


    stop();

    naam.tabIndex =1;
    email.tabIndex =2;
    msg.tabIndex =3;
    Guestbook.tabIndex =4;

    myButton.onRollOver = function(){
    this.onEnterFrame = function(){
    GuestBook.scroll ++;

    if(GuestBook.scroll == GuestBook.maxscroll) delete this.onEnterFrame
    }
    }
    myButton.onRollOut = function(){
    delete this.onEnterFrame;
    }
    myButtup.onRollOver = function(){
    this.onEnterFrame = function(){
    GuestBook.scroll--;
    if(GuestBook.scroll == GuestBook.maxscroll) delete this.onEnterFrame
    }
    }
    myButtup.onRollOut = function(){
    delete this.onEnterFrame;
    }
    NumLow = 0;
    NumHigh = 10;
    loadVariables("GuestBook.php?NumLow="+NumLow+"&Num High="+NumHigh+"&R="+random(999), _self );
    stop();
    And this piece of AS2 scripting is located on the button that's supposed to send the request.

    on (release) {
    if (naam eq "") {
    Status = "je bent je naam vergeten in te vullen";
    } else if (email eq "") {
    Status = "e-mail adres ontbreekt..";
    } else if (msg eq "") {
    Status = "Zonder bericht is het niet mogelijk iets te plaatsen.";
    } else {
    Submit = "Yes";
    NumHigh = 10;
    NumLow = 0;
    Status = "bezig met opslaan ...";
    lv = new LoadVars();
    lv.waarde = naam
    lv.waarde = email
    lv.waarde = msg
    loadVariables("GuestBook.php?naam=" + naam +"&email=" + email +"&msg=" + msg +"&submit=true", _parent, "POST");
    Status = "U vraag / mededeling is geplaatst"
    }
    }
    This is how I named the Variables:

    Variable name (and Instance Name): Guestbook (dynamic text, render text as HTML, multiline)
    Variable name: naam (input text, single line)
    Variable name: email (input text, single line)
    Variable name (instance name input_box): msg (input text, multiline)
    Variable name: status (input text, multiline)
    Variable name: TotaleEntries (dynamic text, render text as HTML, multiline)

    If it's a bit to confusing:
    http://www.mediafire.com/?p72dnjji11vnao7

    The "guestbook" is located in a movieclip called: site_link 13 (the bar that's gonna expend when animated in Frame 17).

  2. #2
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    Is PHP running on the server? Run this in a .php file on from the server:

    PHP Code:
    phpinfo(); 

  3. #3
    Junior Member
    Join Date
    Jun 2009
    Posts
    9
    http://1576527.huweb.nl/Guestbook/guestbook.php

    What am I supposed to look for?

  4. #4
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    Basic trouble shooting: I wanted to make sure you have php running.

    I will look a little more into this and see if I can find out any info for ya,

    -gk

  5. #5
    Junior Member
    Join Date
    Jun 2009
    Posts
    9
    thank you

  6. #6
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I dont really understand I guess..

    1.) you are trying to SEND data to your PHP script.. "&" load data as well? (to update the guest book?).. but I see no place where you are waiting for this data or even whre you are using it?

    I see you sending data using _GET..



    I suggest you try the following.

    1.) dont use loadvariables().. but instead use a load var instance.

    2.) use the sendAndLoad() method on you new instance.. to send some data.. and get a return.

    3.) define your onLoad() handler to parse this return data.

    I am not going to go through all your code/variables.. and have no clue how your return data is formatted.. (I suggest xml as the return data format. much easier to handle and have more control)

    but here is a quick outline of doing it the way I described above..


    actionscript:
    actionscript Code:
    var guestBook:LoadVars = new LoadVars();
    //guestBook.guestName = "abc123";
    //guestBook.guestComment = "Hi, everybody!";
    guestBook.guestName = guestName_field.text;
    guestBook.guestComment = guestComment_field.text;

    guestBook.onLoad = function(success) {
        if (!success) {
            trace("Failed Load PHP script");
        } else {
            trace("CONNECTION MADE");
            trace("RESPONSE: " + guestBook.returnedData);
            guestBook_preview.text += "RESPONSE: " + guestBook.returnedData + newline;
        }
    };

    //check data before sending
    guestBook_preview.text += "PRE-NAME: " + guestBook.guestName + newline;
    guestBook_preview.text += "PRE-COMMENT: " + guestBook.guestComment + newline + newline;
    trace("PRE-ID: " + guestBook.guestName + newline);
    trace("PRE-TARGET: " + guestBook.guestComment + newline);

    guestBook.sendAndLoad("guestBook_script.php", guestBook, POST);


    quick php to handle it.. (this is just a simple return.. not saving data to .txt file like you have, you can edit as you see fit:


    Actionscript Code:
    <?php

        $guestName=$_POST["guestName"];    //targetID being the var sent from flash
        $guestComment=$_POST["guestComment"];  //targetURL being the var sent from flash


        $ip_address = getenv("REMOTE_ADDR");


        $response = "The data sent from Flash was-  ID: $guestName, and URL: $guestComment, sent from IP: $ip_address";


        echo ("&returnedData=$response");

    ?>

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