Form to form integration

badbrad 29 Sep, 2008
Hi,

I have about 3 forms that I want to have flowing into eachother collecting the information from one form to the next. On the final step of the form process, I want all the combined information from all forms submitted to an email. Is this possible and if so, could you please help me configure this setup? I hope I am being clear on what I want. Please ask me more questions if needed.

Thank
Brad
GreyHead 29 Sep, 2008
Hi badbrad,

There are a couple of ways to do this. The main difference is whether you expect people to do all three parts immediately one after the other or if you expect there to be a time gap between them.

If they will do all the parts together then you could create a single form with some conditional php so that it only displayed one page at a time. The form html goes like this
<?php
switch ( $_POST['this_page']) {
  case 1:
    // show one page
    // set $_POST['this_page'] to '2' 
    break;
  case 2:
    // show another page
    // set $_POST['this_page'] to '3' 
    break;
  default:
    // show first page
    // set $_POST['this_page'] to '1' 
    break;
} 
NB This is pseudo code and the detail would need to be thought through.

The second approach is to save the interim data in a database table so that it can be picked up later. To make this work you need to be able to recognise the user again. If they are registered users then you can use their user-id; if not then either you need to give them a unique identifier, the most common approach is to use a cookie but you could ask them to identify themselves with a token of some kind - maybe their email address. Then you look up the token in the database table and re-load their partial data if it exists.

Bob
badbrad 29 Sep, 2008
Ok great, I tried a few things with that code, but can't seem to get it to work. Lets say for example, this is my 2 page form -
<table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr> 
        <td colspan="2" align="center"><h3>Loan Application Form - Contact Details</h3></td>
      </tr>
      
      <tr> 
        <td width="12%" align="right">Title:</td>
        <td width="33%"><input name="title" type="text" size="30"></td>
      </tr>
      <tr> 
        <td align="right">Surname:</td>
        <td><input name="surname" type="text" size="30"> *</td>
	  </tr>
      <tr> 
        <td align="right">First Names:</td>
        <td><input name="first_names" type="text" size="30"> *</td>
   	  </tr>
      <tr> 
        <td align="right">Email:</td>
        <td><input name="email" type="text" id="email" size="30"> *</td>
      </tr>
</table>

*This is where I want it to go to the next page*

<table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr> 
        <td colspan="2" align="center"><h3>Loan Application Form - Occupation Details</h3></td>
      </tr>
      <tr> 
        <td width="12%"> </td>
        <td width="33%"> </td>
      </tr>
      <tr> 
        <td align="right">Occupation:</td>
        <td><input name="title" type="text" size="30"></td>
      </tr>
      <tr> 
        <td align="right">Employer:</td>
        <td><input name="surname" type="text" size="30"> *</td>
	  </tr>
      </table>

Where would I put the switch comments?
Max_admin 30 Sep, 2008
Hi, It should look like this :


<?php
switch ( $_POST['this_page']) {
  case '1':
    //your second code block goes here
    break;
  case '2':
    // your third code block goes here
    break;
  default:
    //default case so your first code block goes here again
    break;
} 
?>












now put all the code above at your HTML box, and at your first code block add this :
<input name="this_page" value = '2' type="hidden">


Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 30 Sep, 2008
Hi badbrad,

To add your code in - simplified a bit to make the structure clearer - here's the Form HTML:
    <?php
    switch ( $_POST['this_page']) {
      case 1:
?>
<h3>Loan Application Form - Occupation Details</h3>
Occupation:<input name="title" type="text" size="30">
Employer:<input name="surname" type="text" size="30"> *
<input type='submit' name = 'submit' />
<input type='hidden' name='this_page' value='2' />
<input type='hidden' name='title' value='<?php echo $_POST['title']; />' />
<input type='hidden' name='surname' value='<?php echo $_POST['surname']; />' />
<input type='hidden' name='first_names' value='<?php echo $_POST['first_names']; />' />
<input type='hidden' name='email' value='<?php echo $_POST['email']; />' />
<?php
        break;
      case 2:
        // show another page
        // set $_POST['this_page'] to '3'
        break;
      default:
?>
<h3>Loan Application Form - Contact Details</h3>
Title:<input name="title" type="text" size="30" />
Surname:<input name="surname" type="text" size="30"/> *
First Names:<input name="first_names" type="text" size="30" / > *
Email:<input name="email" type="text" id="email" size="30" /> *
<input type='submit' name = 'submit' />
<input type='hidden' name='this_page' value='1' />
<?php
        break;
    } 
?>

I hope that the structure of showing the pages and preserving the field values is clear.

Bob
samoht 24 Oct, 2008
Bob using your simplified code the form disappears after hitting submit and it never makes it to the second form??
tsyrphlame 26 Oct, 2008
I'd like to echo this latest comment. When I click 'Next' on my form, all I get is a blank page.

	<?php
		switch ( $_POST['this_page']) {
			case 1:
	?>

<h3>Confirmation</h3>

<table width="520">
<tr>
  <td width="508" valign="top"><h3>Course(s) registered:</h3></td>
  </tr>

<?php 
	if ($_POST['couse1'] == true) {
    	echo "<tr><td valign='top'>Building Influence and Credibility</td></tr>"; 
	}
	if ($_POST['couse2'] == true) {
    	echo "<tr><td valign='top'>Five Practices of Exemplary Leadership</td></tr>"; 
	}
	if ($_POST['couse3'] == true) {
    	echo "<tr><td valign='top'>Situational Leadership</td></tr>"; 
	} 
?>

</table>
<table width="520">
  <tr>
    <td colspan="6" valign="top">  </td>
  </tr>
  <tr>
    <td colspan="6" valign="top"><h3>Contact details:</h3></td>
  </tr>
  <tr>
    <td width="112" valign="top">Name:</td>
    <td colspan="5" align="left"><?php echo $_POST['fullname']; ?></td>
  </tr>
  <tr>
    <td width="112" valign="top">Company:</td>
    <td colspan="5" align="left"><?php echo $_POST['company']; ?></td>
  </tr>
  <tr>
    <td width="112" valign="top">Title:</td>
    <td colspan="5" align="left"><?php echo $_POST['title']; ?></td>
  </tr>
  <tr>
    <td valign="top">Address 1:</td>
    <td colspan="5" align="left"><?php echo $_POST['address1']; ?></td>
  </tr>
  <tr>
    <td valign="top">Address 2:</td>
    <td colspan="5" align="left"><?php echo $_POST['address2']; ?></td>
  </tr>
  <tr>
    <td valign="top">City:</td>
    <td width="177" align="left"><?php echo $_POST['city']; ?></td>
    <td width="41" align="left">State:</td>
    <td width="55" align="left"><?php echo $_POST['state']; ?></td>
    <td width="28" align="left">Zip:</td>
    <td width="79" align="left"><?php echo $_POST['zip']; ?></td>
  </tr>
  <tr>
    <td width="112" valign="top">Email Address:</td>
    <td colspan="5" align="left"><?php echo $_POST['email']; ?></td>
  </tr>
  <tr>
    <td width="112" valign="top">Phone Number:</td>
    <td colspan="5" align="left"><?php echo $_POST['phone']; ?></td>
  </tr>
  
  <tr>
    <td colspan="6">Special Instructions:<br />
      <br />
      <?php echo $_POST['instructions']; ?></td>
  </tr>
</table>
<br><input name="submit" value="Submit" type="submit">

<input type='hidden' name='this_page' value='2' />


	<?php
		break;

		default:
	?>

<table width="520">
<tr>
  <td colspan="2" valign="top"><h3>Select course(s) for registration:</h3></td>
  </tr>
<tr><td width="38" valign="top"><input type="checkbox" name="course1" id="course1"  value='<?php echo $_POST['course1']; ?>'/></td> 
<td width="470" align="left">Building Influence and Credibility</td>
</tr>
<tr><td width="38" valign="top"><input type="checkbox" name="course2" id="course2"  value='<?php echo $_POST['course2']; ?>'/></td> 
<td align="left">Five Practices of Exemplary Leadership<br></td>
</tr>
<tr><td width="38" valign="top"><input type="checkbox" name="course3" id="course3"  value='<?php echo $_POST['course3']; ?>'/></td> 
<td align="left">Situational Leadership<br></td>
</tr>
</table>
<table width="520">
  <tr>
    <td colspan="6" valign="top">  </td>
  </tr>
  <tr>
    <td colspan="6" valign="top"><h3>Contact details:</h3></td>
  </tr>
  <tr>
    <td width="112" valign="top">Name:</td>
    <td colspan="5" align="left"><input type="text" name="fullname" id="fullname" value='<?php echo $_POST['fullname']; ?>' />
    <br /></td>
  </tr>
  <tr>
    <td width="112" valign="top">Company:</td>
    <td colspan="5" align="left"><input type="text" name="company" id="company" value='<?php echo $_POST['company']; ?>' />
    <br /></td>
  </tr>
  <tr>
    <td width="112" valign="top">Title:</td>
    <td colspan="5" align="left"><input type="text" name="jobtitle" id="jobtitle" value='<?php echo $_POST['jobtitle']; ?>' />
    <br /></td>
  </tr>
  <tr>
    <td valign="top">Address 1:</td>
    <td colspan="5" align="left"><input type="text" name="address1" id="address1" value='<?php echo $_POST['address1']; ?>' /></td>
  </tr>
  <tr>
    <td valign="top">Address 2:</td>
    <td colspan="5" align="left"><input type="text" name="address2" id="address2" value='<?php echo $_POST['address2']; ?>' /></td>
  </tr>
  <tr>
    <td valign="top">City:</td>
    <td width="177" align="left"><input type="text" name="city" id="city" value='<?php echo $_POST['city']; ?>' /></td>
    <td width="41" align="left">State:</td>
    <td width="55" align="left">        <select name="state" id="state" value='<?php echo $_POST['state']; ?>'>
          <option value="Alabama" selected>AL</option>
          <option value="Alaska">AK</option>
          <option value="Arizona">AZ</option>
          <option value="Arkansas">AR</option>
          <option value="California">CA</option>
          <option value="Colorado">CO</option>
          <option value="Connecticut">CT</option>
          <option value="Delaware">DE</option>
          <option value="District of Columbia">DC</option>
          <option value="Florida">FL</option>
          <option value="Georgia">GA</option>
          <option value="Hawaii">HI</option>
          <option value="Idaho">ID</option>
          <option value="Illinois">IL</option>
          <option value="Indiana">IN</option>
          <option value="Iowa">IA</option>
          <option value="Kansas">KS</option>
          <option value="Kentucky">KY</option>
          <option value="Louisiana">LS</option>
          <option value="Maine">ME</option>
          <option value="Maryland">MD</option>
          <option value="Massachusetts">MA</option>
          <option value="Michigan">MI</option>
          <option value="Minnesota">MN</option>
          <option value="Mississippi">MS</option>
          <option value="Missouri">MO</option>
          <option value="Montana">MT</option>
          <option value="Nebraska">NE</option>
          <option value="Nevada">NV</option>
          <option value="New Hampshire">NH</option>
          <option value="New Jersey">NJ</option>
          <option value="New Mexico">NM</option>
          <option value="New York">NY</option>
          <option value="North Carolina">NC</option>
          <option value="North Dakota">ND</option>
          <option value="Ohio">OH</option>
          <option value="Oklahoma">OK</option>
          <option value="Oregon">OR</option>
          <option value="Pennsylvania">PA</option>
          <option value="Rhode Island">RI</option>
          <option value="South Carolina">SC</option>
          <option value="South Dakota">SD</option>
          <option value="Tennessee">TN</option>
          <option value="Texas">TX</option>
          <option value="Utah">UT</option>
          <option value="Vermont">VT</option>
          <option value="Virginia">VA</option>
          <option value="Washington">WA</option>
          <option value="West Virginia">WV</option>
          <option value="Wisconsin">WS</option>
          <option value="Wyoming">WY</option>
        </select></td>
    <td width="28" align="left">Zip:</td>
    <td width="79" align="left"><input name="zip" type="text" id="zip"  value='<?php echo $_POST['zip']; ?>' size="10" /></td>
  </tr>
  <tr>
    <td width="112" valign="top">Email Address:</td>
    <td colspan="5" align="left"><input type="text" name="email" id="email" value='<?php echo $_POST['email']; ?>' />
    <br /></td>
  </tr>
  <tr>
    <td width="112" valign="top">Phone Number:</td>
    <td colspan="5" align="left"><input type="text" name="phone" id="phone" value='<?php echo $_POST['phone']; ?>' />
    <br /></td>
  </tr>
  
  <tr>
    <td colspan="6">Special Instructions:<br />
        <textarea name="instructions" id="instructions" value='<?php echo $_POST['instructions']; ?>' cols="60" rows="9"></textarea>
      <br />
       </td>
  </tr>
</table><br><input type='hidden' name='this_page' value='1' />
<input type='submit' name = 'submit' value="Next"/>



<?php
        break;
    }
?>


Max_admin 26 Oct, 2008
what do you have in the form HTML and form onsubmit, show me both! and which onsubmit is this ? onsubmit before email block will not run if you have no emails enabled!

Cheers,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
tsyrphlame 26 Oct, 2008
Ok Max,

I'm obviously new to this, but the above code was all in the Form HTML block, and there is no code in the On Submit blocks...ideally, I'm just looking for a simple registration form with a confirmation page that allows you to go back and edit the form.

Jeremy
Max_admin 26 Oct, 2008
Hi Jeremy, try to search the forums for "confirmation page", I believe there are some ideas, I didn't make one before but the feature will be available out of the box soon!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.