The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
Bypassing a page in a multi-page form - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Bypassing a page in a multi-page form (/showthread.php?tid=293)



Bypassing a page in a multi-page form - Jaace - Sep 22nd, 2009

I have a form that I want to give the user the option to either continue to the next page of the form to fill out more information...or skip that part and complete the order.

When I was looking through the params array, I see the submit_button variable but is there a way to add a different submit button? One that routes to one page and one that goes to another form page or the paypal_submit page? (I'm doing PayPal integration here).

Any help is greatly appreciated! Thanks :-)


RE: Bypassing a page in a multi-page form - Jaace - Sep 22nd, 2009

oops. posted in wrong thread...can't delete :-(


RE: Bypassing a page in a multi-page form - Jaace - Oct 22nd, 2009

Ben,

Do you have any suggestions on how to accomplish this kind of bypassing of a page in a multi-page?


RE: Bypassing a page in a multi-page form - Ben - Oct 22nd, 2009

Oops! Sorry, I missed your post.

Sure! Since you're using the API, you can tell it to redirect to any page you want. Basically, it would work by dynamically constructing the $params to pass to the ft_api_process_form() function.

Here's an example. Pretend the API code at the top of your form page looks like this: (this is the page that you want to redirect to two different locations, depending on the user input)

PHP Code:
<?php
require_once("path/to/form_tools/global/api/api.php");
$fields ft_api_init_form_page("""test");
$params = array(
  
"submit_button" => "submit_button",
  
"next_page" => "next_page.php",
  
"form_data" => $_POST
    
);
ft_api_process_form($params);
?>

So whenever the form on that page is submitted, it will always redirect to next_page.php. What we want to do is choose the location
based on (say) whichever submit button is pressed.

So add the following buttons to your form:

Code:
<input type="submit" name="submit_button" value="Submit! (1)" />
<input type="submit" name="submit_button2" value="Submit! (2)" />

[Note on usability: if the user clicks "enter" on any form field, on many browsers it will pick the FIRST submit button in your form and submit that. So order them in a way that's most logical].

Now, doctor the PHP to figure out which submit button was pressed. If memory serves, it only sends the name-value pair of the submit button that was pressed - not all buttons. So, your PHP could use this info like so:


PHP Code:
<?php
require_once("path/to/form_tools/global/api/api.php");
$fields ft_api_init_form_page("""test");
$params = array(
  
"submit_button" => "submit_button",
  
"next_page" => "next_page.php",
  
"form_data" => $_POST
    
);

// if the user clicked the second button, redirect to a different page
if (isset($_POST["submit_button2"]))
  
$params["next_page"] = "a_different_page.php";

ft_api_process_form($params);
?>

And that's it! If the user clicks the second submit button ("Submit! (2)") they will be redirected to a_different_page.php. Otherwise they get sent to the default ("next_page.php").

I admit, I haven't tested this, but I'm pretty sure it would work fine.

Let me know if you have any trouble or if I didn't explain it very well! Smile

- Ben


RE: Bypassing a page in a multi-page form - Jaace - Oct 22nd, 2009

Hey Ben! Thanks for the quick response; I haven't tried yet but I will be tomorrow and I'll let you know if I run into any problems (which I doubt since your solution is very well explained) Smile

Cheers!


RE: Bypassing a page in a multi-page form - Jaace - Oct 27th, 2009

Hmm...it just keeps loading up the page that I'm on if I click the "bypass" button. Perhaps it's because my form has already been initialized? Do I have to include this second submit button in the building of the form phase and not after the database and everything has been setup?


RE: Bypassing a page in a multi-page form - Peterw - Jan 9th, 2010

Yeah keeps reloading the page for me too if I click the submit2 button.


RE: Bypassing a page in a multi-page form - Peterw - Jan 10th, 2010

The following works for me where I wanted to provide the option of either paying via bank or paypal.

PHP Code:
if (isset($_POST['submit2']))
{
  
$params = array(
    
"submit_button" => "submit2",
    
"next_page" => "success_bank.php",
    
"form_data" => $_POST,
        
"finalize" => true
  
);
}
else
{
  
$params = array(
    
"submit_button" => "submit",
    
"next_page" => "paypal_submit.php",
    
"form_data" => $_POST,
  );