Search Tutorials
c) Setting up the Guest Book entry FormThe main Guest Book entry (or submission) form is shown to the left. This consists of 4 input text boxes and 2 buttons. 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.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|