The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
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 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)" /> [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 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! - 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) 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'])) |