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

Multiple Redirect URL's


  1. bmcrec
    Member

    I have a form that I’m using to register request for my software demo. It comes in two versions Mac and PC. Is there a way to have a drop down menu in the form where the user selects (let’s say) Mac or PC and If a user selects Mac the Redirect URL goes to one page and if the user selects PC the Redirect URL goes to a different page after the form is submitted?

    Posted 17 years ago #
  2. yuniar

    This would require some hack.

    Let say you have a form with id = 2 and your dropdown is having id = 'element_3' (view the HTML source of your form to see it).

    And your dropdown values are:
    1 - PC
    2 - MAC

    Edit your includes/post-functions.php file, search around line 910 - 914:

    if(empty($error_elements) && empty($process_result['custom_error'])){
    	$process_result['status'] = true;
    }else{
    	$process_result['status'] = false;
    }


    Modify the code above to be like this:

    if(empty($error_elements) && empty($process_result['custom_error'])){
    	$process_result['status'] = true;
    	if($form_id == 2){
    		if($table_data['element_3'] == 1){
    			$process_result['form_redirect'] = 'http://www.pc.com';
    		}elseif ($table_data['element_3'] == 2){
    			$process_result['form_redirect'] = 'http://www.mac.com';
    		}
    	}
    }else{
    	$process_result['status'] = false;
    }


    Adjust the id values above as needed.


    MachForm Founder

    Posted 17 years ago #
  3. bmcrec
    Member

    Thanks yuniar that worked perfectly. Your product is amazing.

    I was wondering if it would be possible to take this one step further.

    I have tweaked the includes/helper-functions.php to send an email back to the form submitter and it works great. Since I now have separate Redirect URL’s based on the Mac or PC dropdown value. Is it possible to send a separate email back to form submitters based on this same value? Mac users get one email and PC users get another.
    Thanks

    Posted 17 years ago #
  4. yuniar

    Ok, I assume you have done the modification as explained here:
    http://www.appnitro.com/forums/topic/sending-html-email-back-to-submitter?replies=29

    You will need to modify your hooks/custom_hooks.php file.
    Change this part:

    $email_content =<<<EOT
    ...Put your HTML content here.....
    EOT;
    
    $result['body']	= $email_content;


    To be something like this:

    $email_content_1 =<<<EOT
    ...Put your PC content here.....
    EOT;
    
    $email_content_2 =<<<EOT
    ...Put your Mac content here.....
    EOT;
    
    if($user_input['element_3'] == 1){
       $result['body'] = $email_content_1;
    }elseif($user_input['element_3'] == 2){
       $result['body'] = $email_content_2;
    }


    That should send different emails.


    MachForm Founder

    Posted 17 years ago #
  5. bmcrec
    Member

    Once again, everything worked perfectly.
    Thanks

    Posted 17 years ago #
  6. mrbalderas
    Member

    Yuniar, can your reply 2 above work if I wanted to use this feature as a multiple choice field? I would like to display my choices and when the radio button is selected and submitted it redirects to the appropriate URL.

    Posted 12 years ago #
  7. yuniar

    The above should work with multiple choice as well. However, the code is applicable for version 2, so the line numbers most likely has been changed if you are using version 3.


    MachForm Founder

    Posted 12 years ago #

RSS feed for this topic

Reply