Author Topic: 2 Step Form  (Read 7118 times)

ifsbos

  • Posts: 16
    • View Profile
2 Step Form
« on: September 11, 2008, 07:54:10 pm »
Hello,

This might sound silly, but I have a client who needs a two-step form with one submit button.

The page collects 3 pieces of information from the user. Then he wants the user to click on "Next" or "Click Here" and go to another form that collects other 3 pieces of information. Why not collect all 6 pieces of information on ONE page? That's just it. He wants it on two separate pages but I need to have the list send it all via ONE Submit click instead of 2 for each form.
Anyone has any idea how I can set this up with ListMail Pro?

Here's an example:
http://www.phpclasses.org/browse/file/9073.html

Notice the "NEXT" on the form. This is what I am trying to achieve with LIst Mail. Is it possible.


Thanks.

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
2 Step Form
« Reply #1 on: September 12, 2008, 10:28:15 am »
If both pages are generated with your own PHP script you might take the values from the first form and place them in hidden form elements on the second form, ie:
Code: [Select]
<form method=post action=/path/to/page2.php>
First name: <input type=text name=fname value=""><br>

And in page2.php:
Code: [Select]
<form method=post action=/path/to/signup.php>
<input type=hidden name=fname value="
<?php echo htmlspecialchars($_POST['fname']); ?>
">
Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

ifsbos

  • Posts: 16
    • View Profile
2 Step Form
« Reply #2 on: September 12, 2008, 03:44:00 pm »
Thank you. That seems to work for my multi-part form. The only snag is that I had to make all fields non-mandatory for the code to work. Do you think I need to pass any additional values to acomodate mandatory fields?
Like I said it works great if I uncheck all the mandatory fields. Otherwise it keeps saying that I forgot to fill out something, on the SECOND form.

I've loved your program since it was new. I have used it for probably 3 years now or so.

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
2 Step Form
« Reply #3 on: September 16, 2008, 01:10:26 am »
Thanks for the kind comment! :)

As long as the client provides the first name on page 1 it should be passed through the hidden form element on page 2 to ListMail without generating an error.  Since when ListMail shows an error it might be required to go back -two- pages, you might also want to add a JavaScript check on page 1 to make sure the user has entered something.
Code: [Select]
<form method=post action=/path/to/page2.php onSubmit="if(!document.getElementById('fn').value){ alert('Please enter a first name'); return false; }">
First name: <input type=text id=fn name=fname value=""><br>

If you do enter a first name and ListMail is still saying it is required (when it is enabled) then perhaps you have not set up your hidden form element on page 2 correctly.  Does a "View source" show the data from page 1 in the hidden element?

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

ifsbos

  • Posts: 16
    • View Profile
2 Step Form
« Reply #4 on: September 16, 2008, 07:08:00 am »
It's working great. Thank you. Your sample codes have saved me hours of brain muscle building.