A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: HELP. need help with flash php email form

  1. #1
    Member
    Join Date
    Oct 2006
    Posts
    43

    HELP. need help with flash php email form

    i am trying to make my form except more then just email name and body

    here is my php code
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $feedback = $_POST['feedback'] ;
    $subject = 'Feedback from ';
    $headers = "From: $name <$email>\n";
    $headers .= "Reply-To: $name <$email>\n";

    $to = 'aj@youremail.net';

    $success = mail($to, $subject, $feedback, $headers);
    if($success){
    echo '&sent=OK';
    }else{
    echo '&sent=Error';
    }
    ?>


    my flash does this

    var sendData_lv:LoadVars = new LoadVars();
    var receiveData_lv:LoadVars = new LoadVars();
    var formValidated:Boolean;
    var errorMessages:Array = new Array();

    receiveData_lv.onLoad = function():Void{
    trace(this.sent);
    if(this.sent == "OK"){
    message0_txt.text = "Thank you for your feedback";
    }else{
    message0_txt.text = this.sent;
    }
    }


    submit_btn.onRelease = function() {
    clearTextFields();
    errorMessages.length = 0;
    formValidated = checkForm();
    if (formValidated) {
    sendData_lv.name = name_txt.text;
    sendData_lv.email = email_txt.text;
    sendData_lv.feedback = feedback_txt.text;
    (sendData_lv.email);
    ("valid");
    sendData_lv.sendAndLoad("email.php?ck="+new Date().getTime(), receiveData_lv);
    } else {
    for (var i = 0; i<errorMessages.length; i++) {
    _root["message"+i+"_txt"].text = errorMessages[i];
    trace(errorMessages[i]);
    }
    }
    };


    function checkForm():Boolean {
    if (name_txt.text == "") {
    errorMessages.push("Please enter your name.");
    }
    if (email_txt.text == "") {
    errorMessages.push("Please enter your email address.");
    } else if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
    errorMessages.push("Please enter a valid email address.");
    }
    if (feedback_txt.text == "") {
    errorMessages.push("Please enter some feedback");
    }
    if (errorMessages.length == 0) {
    return true;
    } else {
    return false;
    }
    }
    function clearTextFields():Void {
    for (var i = 0; i<errorMessages.length; i++) {
    _root["message"+i+"_txt"].text = "";
    ;
    }
    }


    i want to add atleast 3 to four more fields to this any help or direction would be great

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Posts
    238
    Simple. Add a few more fields in flash and assign them to sendData like you did everything else:
    e.g. sendData_lv.city = city_txt.text;

    Then, attach those to your feedback variable in PHP like so:
    $feedback = "Feedback: ".$_POST['feedback'] ."\r\n";
    $feedback.= "City: ".$_POST['city']."\r\n";

    Notice the \r\n (linebreak in a plain text e-mail) and the dot-equals which means "add this to the feedback variable without replacing it".

    I also added "City: " and "Feedback: " so you knew what the responses where to in your e-mail.

    Make sense?

  3. #3
    Member
    Join Date
    Oct 2006
    Posts
    43
    thanks. yeah the dot is where i was messing up. Thanks

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