A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: My guestbook not working :(

  1. #1
    The Metamorphic Mutant Mystique_MHz's Avatar
    Join Date
    Mar 2002
    Location
    Orlando, FL
    Posts
    218

    My guestbook not working :(

    I downloaded a guestbook tutorial from flashkit and it doesn't work!!!

    here's the url to the site: http://www.dc-media.com
    [note: site not finished]

    I changed my permissions on the web server [iPowerWeb.com] but something is wrong. Can someone please take a look at it and see if the php code is off or something? For some reason... it's not writing to the .txt file!!!

    Code:
    <?
    ############### Begin GuestBook Script #####################################
    
    ##The first 3 lines use a regular expression to match a pattern then
    replace it with nothing.  The only reason for this is so we only
    allow necessary characters to be entered into the guestbook. This also takes out slashes which are sometimes added in the post headers to make the string friendly.  
    You can erase or take these lines out if you want.
    
    	$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
    	$Email = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Email);
    	$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
    
    	$Website = eregi_replace("http://", "", $Website);
    	$Website = ereg_replace("[^A-Za-z0-9 \@\.\-\/\'\~\:]", "", $Website);
    
    	$Name = stripslashes($Name);
    	$Email = stripslashes($Email);
    	$Website = stripslashes($Website);
    	$Comments = stripslashes($Comments);
    
    ####################################################################################
    ########### Reading and Writing the new data to the GuestBook Database #############
    
    if ($Submit == "Yes") {
    #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"); 
    	$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.
    
    	$Input = "Name: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></b></u><br>Website: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></b></u><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+"); 
    	fwrite($fp, $New, 80000); 
    	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, 80000); 
    	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 "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
    	for ($n = $NumLow; $n < $NumHigh; $n++) {
    	print $DataArray[$n];
    		if (!$DataArray[$n]) {
    		Print "<br><br><b>NO MORE ENTRIES</b>";
    		exit;
    		}
    	}
    
    ?>
    I really need this to work ASAP... your help is greatly appreciated

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    add lines like
    $Name = $_POST[Name];
    near the top of your script for all vars you are receiving from your movie (assuming the movie is using POST method to send)

    Musicman

  3. #3
    The Metamorphic Mutant Mystique_MHz's Avatar
    Join Date
    Mar 2002
    Location
    Orlando, FL
    Posts
    218
    Hello Musicman,

    I have this code on my first key frame on the main stage
    Code:
    NumLow = 0;
    NumHigh = 10;
    loadVariablesNum("guestbook.php?NumLow="+NumLow+"&NumHigh="+NumHigh+"&R="+random(999), 0);
    stop();
    How do I change it to say post?
    Thnaks for your help

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

    weird...
    how do $Name, $Email etc. get into your script at all if you are sending numLow and numHigh only?

    I am not kidding here, some servers are set to issue warning messages that interfere badly with reading variables into flash. Maybe you should slightly reorder the script

    Now, for the theory:
    loadvariables ... GET adds ALL current variables (those on the main timeline, if you use the loadvariablesnum variant) to the end of the url (as you do with some of them now)
    loadvariables ... POST again sends ALL vars with the post method
    PHP can use $_REQUEST[varname] to pick up a variable sent either method, or $_GET[varname] and $_POST[varname] to pick up only variables sent using that method

    Musicman

  5. #5
    The Metamorphic Mutant Mystique_MHz's Avatar
    Join Date
    Mar 2002
    Location
    Orlando, FL
    Posts
    218
    Your guess is as good as mine... I got the code from this tutorial:
    http://www.flashkit.com/tutorials/Dy...-705/index.php

    I simply modified the design of it. If it's done wrong... then perhaps it shouldn't be available as a tutorial here on FK!

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