Jump to content

Conditional Form - Using if statement and div tags


Dan06

Recommended Posts

I've put two forms on one page, and I want to display one of them based on the user's previous page selection. My idea was to use an if statement and based on that print a particular div id. I know that in javascript I could use the .getElementById method to print a selected div id. But how would I print a particular div id in php? Below is the code I've put together so far:

 

<?php if($_SESSION['JoinSession'] == "Business"){ 
	  echo "div id='businessprofile'";
	  }?>
          <div id = "businessprofile">
          <form action="<?php echo $editFormAction; ?>" method="post" name="busProForm" id="busProForm">
              <table align="center">
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">Company Name:</td>
                  <td><input type="text" name="CompanyName" value="<?php echo htmlentities($row_profileRegister['CompanyName'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">Telephone Number:</td>
                  <td><input type="text" name="TelNumber" value="<?php echo htmlentities($row_profileRegister['TelNumber'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">Street:</td>
                  <td><input type="text" name="Street" value="<?php echo htmlentities($row_profileRegister['Street'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">Street 2:</td>
                  <td><input type="text" name="Street2" value="<?php echo htmlentities($row_profileRegister['Street2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">City:</td>
                  <td><input type="text" name="City" value="<?php echo htmlentities($row_profileRegister['City'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">State:</td>
                  <td><input type="text" name="State" value="<?php echo htmlentities($row_profileRegister['State'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right">Zip:</td>
                  <td><input type="text" name="Zip" value="<?php echo htmlentities($row_profileRegister['Zip'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"> </td>
                  <td> </td>
                </tr>
                <tr valign="baseline">
                  <td nowrap="nowrap" align="right"> </td>
                  <td><input type="submit" value="Update record" /></td>
                </tr>
              </table>
              <input type="hidden" name="MM_update" value="busProForm" />
              <input type="hidden" name="Id" value="<?php echo $row_profileRegister['Id']; ?>" />
            </form>
            </div>
          <p> </p>
        

I've used exactly that type of code and unfortunately, it's not working - both forms are still being shown.

<?php if($_SESSION['JoinSelection'] == "Individual"){
	  echo "<div id=individualProfile>";
	  }?>

Any ideas why both forms are still being shown?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.