Results 1 to 2 of 2

Thread: Flash form (check fields)

  1. #1
    Join Date
    Dec 2007
    Location
    Mississauga
    Posts
    166
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default Flash form (check fields)

    I have a simple email form on my site that is a flash site that when someone hits submit a php page sends the data to my email. With it being a simple type of form it does not check the fields before submiting and I don't know why people do this but they hit submit without filling anything in.

    Are there any tutorials or can anyone help me so that if certain fields are not filled in, the submit button cannot be used or it will prompt people to fill the fields.

    Here is my action script code for the mc that holds the fields
    Code:
    onClipEvent(data){
    	// show welcome screen
    	_root.content_mc.contact_mc.gotoAndPlay(33);
    }
    Here is the php page
    Code:
    <?php
    /***************************************************\
     * PHP 4.1.0+ version of email script. For more
     * information on the mail() function for PHP, see
     * http://www.php.net/manual/en/function.mail.php
    \***************************************************/
    
    
    // First, set up some variables to serve you in
    // getting an email.  This includes the email this is
    // sent to (yours) and what the subject of this email
    // should be.  It's a good idea to choose your own
    // subject instead of allowing the user to.  This will
    // help prevent spam filters from snatching this email
    // out from under your nose when something unusual is put.
    
    $sendTo = "xxxx@xxxxx.com";
    $subject = "Inquiry/Comment from site";
    
    // variables are sent to this PHP page through
    // the POST method.  $_POST is a global associative array
    // of variables passed through this method.  From that, we
    // can get the values sent to this page from Flash and
    // assign them to appropriate variables which can be used
    // in the PHP mail() function.
    
    $headers  = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers .= "From: " . $_POST["name"] ."<" . $_POST["email"] .">\r\n"; 
    $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
    
    // now we can add the content of the message to a body variable
    $message = "From: " . $_POST["name"] ." " . $_POST["email"] ." " . $_POST["message"] ."\r\n";
    
    // once the variables have been defined, they can be included
    // in the mail function call which will send you an email
    mail($sendTo, $subject, $message, $headers);
    
    ?>
    *Note I am aware there is a slight flaw in the code so that when I get email responses the address bar has a bunch of excess code in it I am still working on it, but as long as the emails are getting to me and I can get names, email address and comment from it, that's fine for me for now.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Do you want to do this within Flash? Or is it enough to block blank emails on the server side?

    Here is a tutorial on how to validate entries through your PHP script.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •