First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

c) Setting up the Guest Book entry Form

The main Guest Book entry (or submission) form is shown to the left.  This consists of 4 input text boxes and 2 buttons.  The entry forms are located inside of a movie clip. Their is no need to give this movie clip an instance name in this case.  Also in the Fla, above this form their is an additional text field named 'Status' - this is used to display messages to the user when filling out the form and submitting it.

The 4 input text boxes are named: Name, Email, Website, and Comments - respectively.  The first 3 are single line text boxes.  The comments text box is a multi-line input text box.  Make sure that you do not check the 'HTML' check box off for any of these.  Also it's always a good idea to set the max number of characters (max Chars) that can be entered in these boxes (especially the Comments text box) otherwise people will be able to enter large amounts of text into the comments area.  In my example I have the comments limited to 240 characters - you can change yours to whatever you want.  That's just one way to check how much data has been entered, you should add other checks to limit the amount of text entered if you feel it's necessary.

The following code is located on the Submit button:

on (release) {
	if (Name eq "") {
		_root.Status = "Please enter your name";
	} else if (Email eq "") {
		_root.Status = "Please enter email Address";
	} else if (Website eq "") {
		_root.Status = "Please enter the URL to your website";
	} else {
		Submit = "Yes";
		NumHigh = 10;
		NumLow = 0;
		_root.GuestBook = "Processing..   Loading New... ";
		loadVariablesNum ("GuestBook.php", 0, "POST");
		_root.Status = "Your entry has been submitted.  You should see your comments appear immediately";
		gotoAndStop (2);
	}
}

The first portion of this code checks to make sure that the fields where filled out.  If they where not filled out correctly an error message will appear in the Status Text box.

If everything was filled out successfully the variable Submit is set to 'yes'.  This is an important aspect and will be further explained in the PHP script.  Then the variables NumHigh and NumLow are set again to their default values of 0 and 10, respectively.  The Guest book text field is then assigned a temporary value to let the user know that the entries are being loaded.  The next line uses the loadVariablesNum function to send all of the variables in this movie clip to the script which will add the entry to our text file database.  After that a success message is shown in the Status text field and the movie clip goes to the second frame where a Thank You message is displayed.

At this point the script is called, where it adds the new entry and returns the new entry as well as the others back to the Flash movie.   In this way the user will see his entry appear in the Guest book right after the submit button is pressed.

» Level Advanced

Added: 2001-12-21
Rating: 8.92 Votes: 200
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content and applications. Specialty's include SQL, PHP, Perl, and XML.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.