A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: [F8] Feedback Form:eMail

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    [F8] Feedback Form:eMail

    Hello everybody.

    Can anyone point out any tutorials that are easy to understand and will teach me how to send a email using a .cgi script and flash's loadVariables? I been using this Flash 5 Bible but that don't seem to work, actually EVERY tutorial i get on a book doesn't seem to work!
    Im rubbish with perl scriptile language.

    Thanks
    Tongxn.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    more or less...the FLASH (AS) will be the same...

    its the backend script that will be different. Sorry I dont have any examples using CGI..only PHP...

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    ok anything will do!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    does your web host support PHP?

    (if not, drop them..its free, and should be offered as such)

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    I can walk you through how to set up a loadVar Object..and send if off to a PHP script, that also returns a message, saying it went "OK" or "NOT OK"...

  6. #6
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    Code:
    on (release) {
    	
    	sendIt = new LoadVars();
    		//   user details   //
    		// here we're collecting the text that was input into the textFields in your form.
    		sendIt.userName = userName_txt.text;
    		sendIt.userEmail = userEmail_txt.text;
    		sendIt.userPhone = userPhone_txt.text;
    		sendIt.extraData = extraData_txt.text;
    
    	
    	// usually you would NOT declare an 'onLoad' action, but since we are using 'sendAndLoad' instead of 'load' 
    	// for our action we can declare a group of events to excute depending on the outcome of the email atempt.
    		
    	sendIt.onLoad = function(success) {
    		if (success) {
    			//mailSent is a variable echo'd in the PHP file. 
    			response_txt.text = sendIt.mailSent;
    			trace("vars loaded/reply returned");
    			trace("Outcome: "+sendIt.mailSent);
    		}
    	}
    
    	// using sendAndLoad, lets us declare an object in the paramters to 'handle' the return from our PHP file
    	// in this example were using the SAME object that we used to gather and SEND the data to handle the LOADing of the data response.
    	sendIt.sendAndLoad("http://www.yourdomain.com/tryEmail.php", sendIt, POST);
    	trace ("sending vars");
    }
    so basically form the example above...

    you should have '4' input fields on your stage. (and 1 button, with this code on it)
    the input field names should be as follows:

    username_txt
    userEmail_txt
    userPhone_txt
    extraData_txt

    (you can change these gather whatever data you want though)

    this is the PHP script you should have to handle this example above. (I have added some HTML tags so the email has some minor "color/formatting")



    PHP Code:
    <?php
         

    $cuserName
    =$_POST["userName"];
    $userEmail=$_POST["userEmail"];
    $userPhone=$_POST["userPhone"];
    $extraData=$_POST["extraData"];

    $MailTo "recipient@email_here.com";

    $Subject "Email Subject Line Here";


    $Body "<B><font color=#A80B0B>From: </font></B>$userName<BR><B><font color=#A80B0B>E-mail:</font></B> <A HREF=mailto:$userEmail>$userEmail</A><BR><B><font color=#A80B0B>Phone: </font></B>$userPhone<BR><br><br><B><font color=#000000>Extra Data/Comments: </font></B><BR><BR>$extraData<BR>";

    $headers "Content-type: text/html; charset=iso-8859-1\r\n"
    $headers .= "From: Whoever the email should be from";

    $sendMail mail($MailTo"$Subject""$Body""$headers"); 


    if(
    sendMail) { 
      echo (
    "&mailSent=Successfully!");
    } else {
          echo (
    "&mailSent=Unsuccessfully!");
    }

    ?>
    I think that should do it...

  7. #7
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Looks clever, cant you do the $Subject and all that using getURL?
    I'll try it out,
    Thanks whispers.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

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