This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

[closed] Autoresponder message variations.


  1. panama
    Member

    I have an application that uses several forms. However, one of the forms sends an e-mail to the user which has content that varies dependant upon the option they have selected in a drop-down menu.

    The drop-down menu only exists in this one form. It is identified as template variable {element_4}. This doesn't exist in the other forms.

    Essentially what I want to do is (using pseudo-code) :

    if {element_4} exists then
    {
    if {element_4} = 'abc...' then message content = 'content 1'
    else if {element_4} = 'def...' then message content = 'content 2'
    else if {element_4} = 'ghi...' then message content = 'content 3'
    else if {element_4} = 'jkl...' then message content = 'content 4'
    }

    else message content = normal content

    Could you give me some code to add into the functions to achieve this?

    I appreciate your help!

    Posted 15 years ago #
  2. yuniar

    Hmm.. I can only give you some pointer on this, since it would require pretty much custom code.

    Basically, you need to modify the code which process the form submission, which is includes/post-functions.php, particularly process_form() function.

    Around line 1153, you'll find the code which set the content of the email:

    //content
    if(!empty($esr_content)){
    	$user_email_param['content'] = $esr_content;
    }else{
    	$user_email_param['content'] = '{entry_data}';
    }


    You need to put your ifs there, to set the email content based on user input.
    You can use $table_data variable to get user input.

    For example:

    if($table_data['element_4'] == 'abc'){
      $user_email_param['content'] = 'content 1';
    }elseif($table_data['element_4'] == 'def'){
      $user_email_param['content'] = 'content 2';
    }


    MachForm Founder

    Posted 15 years ago #
  3. panama
    Member

    Hi yuniar

    That's great... I'm almost there, but just have one debugging issua. Perhaps you can spot the problem.

    It seems that $table_data['element_4'] is a string variable in the form of a number (since element_4 is the result of a drop-down menu, and the numeric value defines the option number).

    So why then does the following code always result in $user_email_param['content'] containing the word "Rhinoplasty" (i.e. the 14th option) no matter what number $table_data['element_4'] contains ??

    Here's the code:

    if($table_data['element_4'] == "1"){
                                    $user_email_param['content'] = $mailbody1."Abdominoplasty".$mailbody2;
                                    }elseif($table_data['element_4'] == "2"){
                                    $user_email_param['content'] = $mailbody1."Blepharoplasty".$mailbody2;
                                    }elseif($table_data['element_4'] == "3"){
                                    $user_email_param['content'] = $mailbody1."Body-Lifting-Procedures".$mailbody2;
                                    }elseif($table_data['element_4'] == "4"){
                                    $user_email_param['content'] = $mailbody1."Breast-Augmentation".$mailbody2;
                                    }elseif($table_data['element_4'] == "5"){
                                    $user_email_param['content'] = $mailbody1."Breast-Reduction".$mailbody2;
                                    }elseif($table_data['element_4'] == "6"){
                                    $user_email_param['content'] = $mailbody1."Breast-Uplift".$mailbody2;
                                    }elseif($table_data['element_4'] == "7"){
                                    $user_email_param['content'] = $mailbody1."Brow-Lift".$mailbody2;
                                    }elseif($table_data['element_4'] == "8"){
                                    $user_email_param['content'] = $mailbody1."Facelift".$mailbody2;
                                    }elseif($table_data['element_4'] == "9"){
                                    $user_email_param['content'] = $mailbody1."Facial-Implants".$mailbody2;
                                    }elseif($table_data['element_4'] == "10"){
                                    $user_email_param['content'] = $mailbody1."Gynecomastia".$mailbody2;
                                    }elseif($table_data['element_4'] == "11"){
                                    $user_email_param['content'] = $mailbody1."Liposuction".$mailbody2;
                                    }elseif($table_data['element_4'] == "12"){
                                    $user_email_param['content'] = $mailbody1."Non-Surgical".$mailbody2;
                                    }elseif($table_data['element_4'] == "13"){
                                    $user_email_param['content'] = $mailbody1."Otoplasty".$mailbody2;
                                    }elseif($table_data['element_4'] == "14"){
                                    $user_email_param['content'] = $mailbody1."Rhinoplasty".$mailbody2;
                                    }else {
                                    $user_email_param['content'] = $mailbody1."Abdominoplasty".$mailbody2;
                                    }

    Sorry to trouble you with this basic PHP stuff. But perhaps you can immediately spot the issue.

    Thanks.

    Posted 15 years ago #
  4. panama
    Member

    Update.... I've now got it all sorted out. It was necessary that the default form entry remain blank for the new code to be triggered.

    I'm very impressed with your coding and the reliability of the scripts!

    Thanks yuniar

    Posted 15 years ago #
  5. yuniar

    awesome :-)


    MachForm Founder

    Posted 15 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.