A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: flash as3 php contact form help

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    75

    flash as3 php contact form help

    The flash isnt talking to php. I hope someone can see the changes I need to make to fix it. Thanks in advance.

    Here is my php code:

    Code:
    <?php
    
    /************************************************************
    mailform.php
    *************************************************************/
    
    $recipient = "[email protected]"; 
    $subject = "Automail";
    
    //variables from swf
    $name = $_POST['textName'];
    $email = $_POST['textEmail'];
    $message = $_POST['textMessage'];
    $results= $_POST['textResults'];
    
    $mail = "Contact from $name email $email
    has left the following message: $message "; 
    
    mail($recipient, $subject, $message, "From: $name"); 
    
    print &results="Data Sent... Thank You.";
    
    ?>
    here is my flash code:
    Code:
    var variables:URLVariables = new URLVariables();
    var varSend:URLRequest = new URLRequest("mailform.php");
    var varLoader:URLLoader = new URLLoader;
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    
    stop();
    
    //sets focus to the Name text box
    stage.focus = name_txt;
    
    
    //method to submit form
    submit_btn.addEventListener(MouseEvent.CLICK, sendData);
    
    
    
    //function called from method, contains validation logic and var data to be sent to form
    function sendData(event:MouseEvent):void{
    	
    	//validate form fields
    	if(!name_txt.length) {
    		results_txt.text = "Please enter your name.";	
    	} else if(!email_txt.length) {
    		results_txt.text = "Please enter an email address";
    	}else if(!validateEmail(email_txt.text)) {
    		results_txt.text = "Please enter a VALID email address";
    	} else if(message_txt.length <= 1) {
    		results_txt.text = "Please enter a message.";
    	} else {
    		results_txt.text = "Sending...";
    		
    		//sends the text box variables to mailform.php by calling the varSend method
                    //these lines are commented out for testing purposes
       		variables.textName = name_txt.text;
       		variables.textEmail = email_txt.text;
       		variables.textMessage = message_txt.text;
    		variables.textResults = results_txt.text;
       		varLoader.load(varSend);
    		
    	
    		trace("Email: "+email_txt.text);
    		trace("Text length: "+message_txt.length);
    		trace("Valid email: "+validateEmail(email_txt.text));
    		trace("Message: "+message_txt.text);
    		trace("Form validated");
    		
    		//moves mc timeline to frame 2
        	//gotoAndStop(2);
    	}
    }

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    where is the php file in relation to your swf ?

  3. #3
    Member
    Join Date
    Aug 2008
    Posts
    75
    they're neighbors

  4. #4
    Member
    Join Date
    Aug 2008
    Posts
    75
    I think I figured it out it was a problem with the php trying to print the result text to the flash dynamic text field

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