Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member nickroz's Avatar
    Join Date
    Oct 2004
    Location
    Shelby Twp, MI
    Posts
    24
    Member #
    7772
    I just designed a Flash sendmail form with some programmed error boxes so people can't send me blank emails.

    http://www.nickroz.com/flash/nickroz_menu.swf - click on "CONTACT"

    I have encountered a bug: all boxes can be left blank, and it will send out a blank email on the first press of 'SUBMIT." Try it again and it will have the correct error box.

    Don't worry about sending me emails - I have Mail set to delete the blanks right now.
    Here's the code on the 'submit' button:
    Code:
    on (release) {
    	//Deal with incomplete fields here, in this case prompt the user with a message box
    	if (inputname eq "" and inputemail eq "" and inputmessage eq "") {
    		messageBox.messageText = "Enter something";
    		messageBox.gotoAndPlay(1);
    	} else if (inputname eq "") {
    		messageBox.messageText = "Your name is required";
    		messageBox.gotoAndPlay(1);
    	} else if (inputemail eq "") {
    		messageBox.messageText = "Enter a valid email address";
    		messageBox.gotoAndPlay(1);
    	} else if (inputmessage eq "") {
    		messageBox.messageText = "Enter a message";
    		messageBox.gotoAndPlay(1);
    	} 
    	// if all the required data has been provided.
    	if (inputname ne "" and inputemail ne "" and inputmessage ne "") {
    		// call the php script to send the msg.
    		loadVariablesNum("sendmail.php", 0, "POST");
    		// let the user know how things went via the message box.
    		messageBox.messageText = "Message Sent";
    		messageBox.gotoAndPlay(1);
    		//Clear the fields so its ready to send again.
    		inputname = "";
    		inputemail = "";
    		inputmessage = "";
    	}
    }
    So how can I change this to make it function correctly?

  2.  

  3. #2
    Senior Member raspberryh's Avatar
    Join Date
    Aug 2004
    Location
    Erie, PA
    Posts
    882
    Member #
    7208
    Liked
    1 times
    Well, this could be wrong, but it looks to me like when the user clicks the button, it executes for first if-else statement - it checks to see if there is anything in your text boxes, and if there isn't, then it writes something like "Enter a message", etc. After doing this, it continues down the code to the last if-statement which says that if there are no blank fields, then call the php script, etc. Since you have written something in those blank fields, then the fields are no longer blank, so the last if-statement can execute right away (without giving the user a chance to fill in the fields).
    I could be wrong, but I think that may be the problem. Try instead, putting your last if statement actually FIRST, so that in the case that any of them are blank, it will NOT call the php script, and instead it will notify the user, like this:

    on (release) {

    // if all the required data has been provided.
    if (inputname ne "" and inputemail ne "" and inputmessage ne "") {
    // call the php script to send the msg.
    loadVariablesNum("sendmail.php", 0, "POST");
    // let the user know how things went via the message box.
    messageBox.messageText = "Message Sent";
    messageBox.gotoAndPlay(1);
    //Clear the fields so its ready to send again.
    inputname = "";
    inputemail = "";
    inputmessage = "";
    }
    else{
    //Deal with incomplete fields here, in this case prompt the user with a message box
    if (inputname eq "" and inputemail eq "" and inputmessage eq "") {
    messageBox.messageText = "Enter something";
    messageBox.gotoAndPlay(1);
    } else if (inputname eq "") {
    messageBox.messageText = "Your name is required";
    messageBox.gotoAndPlay(1);
    } else if (inputemail eq "") {
    messageBox.messageText = "Enter a valid email address";
    messageBox.gotoAndPlay(1);
    } else if (inputmessage eq "") {
    messageBox.messageText = "Enter a message";
    messageBox.gotoAndPlay(1);
    }
    }
    }

    Also, I don't see where you handle the case where if say, the user did enter their name but NOT their email or a message. It seems like you only handle cases where the user enters all three, or just one. Instead, maybe you should have multiple ifs instead of if-else's.

    if (inputname eq "" and inputemail eq "" and inputmessage eq "") {
    messageBox.messageText = "Enter something";
    messageBox.gotoAndPlay(1);
    } else {
    // reset messagebox text
    messageBox.messageText = "";

    // the next three if-statements tag on to messageText whatever instructions are necessary for the user
    if (inputname eq "") {
    messageBox.messageText += "Your name is required";

    }
    if (inputemail eq "") {
    messageBox.messageText += "Enter a valid email address";

    }
    if (inputmessage eq "") {
    messageBox.messageText += "Enter a message";

    }

    // display text
    messageBox.gotoAndPlay(1);
    }

    Well, I hope that helped!

    Heather
    choosy developers choose gif!
    website | paintings | blog

  4. #3
    Junior Member nickroz's Avatar
    Join Date
    Oct 2004
    Location
    Shelby Twp, MI
    Posts
    24
    Member #
    7772
    Thanks for replying Heather. I tried switching my code around but still got a bug. It correctly said, "enter something" when the submit button was pressed with blank fields. The new problem happened when all 3 forms were filled out, then the submit button was hit - it said "enter something" and reset the form.

    I think this error would be more frustrating to the user who just lost the email he typed, so I'm going to keep my code as the original until I get sick of my inbox flooded with blank emails. Thanks for helping out though. Nick


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:09 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com