Skip to main content
Participating Frequently
April 13, 2010
Question

Making an email form dynamic?

  • April 13, 2010
  • 2 replies
  • 463 views

I have a registration form here:

www.pitlanepass.com/pages/register.php


I'm in the very early stage of learning php so the form is created in dreamweaver and emailmeform.com so save that bullet for later!! :bangb:
I have populated several fields using a mysql database and they display and email in a format i'm happy with. for now. The small issue I have is when the organisation is selected and the next field (class) is displayed it lists all classes from the four organisations. Some are repeated and the list is uneccessarily long. For example, Southern Supermoto has only 3 classes but lists all 25! This method allows a registrant to possibly select a class that doesn't exist. I've had similar issues elsewhere ith rider profiles but used $_GET to pull variables from the url but I don't think thats how to achieve it here. Any pointers would be most welcome!!
Here's the code snippet from the form...

<label>Organisation</label>
<select name="FieldData1">
<?php do { ?>
<option value="<?php echo $row_rsRegisterorgselect['orgname']; ?>"><?php echo $row_rsRegisterorgselect['orgname']; ?></option>
<?php } while ($row_rsRegisterorgselect = mysql_fetch_assoc($rsRegisterorgselect)); ?>
</select>

<br />

<label>Class</label>
<select name="FieldData2">
<?php do { ?>
<option value="<?php echo $row_rsClassregister['catname']; ?>"><?php echo $row_rsClassregister['catname']; ?></option>
<?php } while ($row_rsClassregister = mysql_fetch_assoc($rsClassregister)); ?>
</select>
This topic has been closed for replies.

2 replies

Participating Frequently
April 14, 2010

I've now uploaded a working version of what I want to achieve but it's not the slickest of ways I don't believe. I use a jump menu form to put a value to orgname in the url. The main form then sits below and the class (categories in the code!) options (it's the riders skill and bike size) gets filtered by the orgname. It's stops a registrant from selecting an organisation/class combination that doesn't exist. I think it's a bit agricultural to use to use two forms and $_GET to achieve this though..The select statement is this:

mysql_select_db($database_connPitlane, $connPitlane);
$query_rsClassregister = sprintf("SELECT catID, catname FROM categories WHERE categories.catorganisation=%s ORDER BY catID ASC ", GetSQLValueString($varClassregister_rsClassregister, "text"));
$rsClassregister = mysql_query($query_rsClassregister, $connPitlane) or die(mysql_error());
$row_rsClassregister = mysql_fetch_assoc($rsClassregister);
$totalRows_rsClassregister = mysql_num_rows($rsClassregister);

and the html in the form snippet is this:

<label>Class</label>
    <select name="FieldData2" class="setwidth">
      <?php do { ?>
      <option value="<?php echo $row_rsClassregister['catname']; ?>"><?php echo $row_rsClassregister['catname']; ?></option>
     <?php } while ($row_rsClassregister = mysql_fetch_assoc($rsClassregister)); ?>    
    </select>

Hopefully i've explained it enough but like I say, i'm really just starting out!! :-)

Participating Frequently
April 14, 2010

I went to the url you posted but it is not working. Did you remove the page? Can you give us the correct url so we can see the workflow? A picture = 1000 words.

Participating Frequently
April 14, 2010

Sorry, my mistake. The page was working using $_GET when viewed locally but when I uploaded the page to the remote server it stopped working! I know where the problem probably is (my first attempt at an if/else statement) and hope to have a working version to show tomorrow. I think i'm going to have to shape up quickly on my knowledge of php to go any further!! Thaks for your patience!!

Participating Frequently
April 14, 2010

Sounds like a SQL problem. What does your select statement look like?