有什么方法可以合并这段代码吗?

发布于 2024-09-01 20:21:48 字数 21792 浏览 7 评论 0原文

我正在构建一个 PHP 注册表,其中包含最多 20 名运动员的以下字段:

名字 中间名首字母 姓氏 联合会号码 地址 城市 州 邮政编码 出生日期 SSN 电话 电子邮件

我只浏览了每个战斗机的 7 个字段,而且我的 php 文件非常大(超过 40kb)。有什么方法可以整合这些代码吗?我还必须验证每个字段的信息(正如我所说 - 20 名运动员 x 12 个字段 = 单页上的 240 次验证)。

如果我可以发送任何进一步的代码,请告诉我!

<form id="Form"  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="Form" onsubmit="return Enroll_Form_Validator(this)">
<p class="title">Your Fighters' Information</p>
<p>Please complete the following fields with your <span style="color:red;"> Fighters' Information</span> to continue your enrollment.</p>
<br />

<?php
    // if $errors is not empty, the form must have failed one or more validation 
    // tests. Loop through each and display them on the page for the user
    if (!empty($errors))
    {
      echo "<div class='error'>Please fix the following errors:\n<ul>";
      foreach ($errors as $error)
        echo "<li>$error</li>\n";

      echo "</ul></div>"; 
    }    
?>

<?php if ($_SESSION['Num_Fighters'] > "0") { ?>
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F1FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F1MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F1LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F1FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F1SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN1']; ?>" /> - 
        <input type="text" name="F1SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN2']; ?>" /> - 
        <input type="text" name="F1SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F1DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F1DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F1DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F1Address" value="<?php echo $fields['F1Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F1City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F1State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F1Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F1Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone1']; ?>" /> ) 
        <input type="text" name="F1Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone2']; ?>" /> - 
        <input type="text" name="F1Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F1Email" value="<?php echo $fields['F1Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "1") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F2FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F2MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F2LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F2FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F2SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN1']; ?>" /> - 
        <input type="text" name="F2SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN2']; ?>" /> - 
        <input type="text" name="F2SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F2DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F2DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F2DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F2Address" value="<?php echo $fields['F2Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F2City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F2State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F2Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F2Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone1']; ?>" /> ) 
        <input type="text" name="F2Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone2']; ?>" /> - 
        <input type="text" name="F2Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F2Email" value="<?php echo $fields['F2Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "2") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F3FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F3MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F3LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F3FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F3SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN1']; ?>" /> - 
        <input type="text" name="F3SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN2']; ?>" /> - 
        <input type="text" name="F3SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F3DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F3DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F3DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F3Address" value="<?php echo $fields['F3Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F3City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F3State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F3Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F3Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone1']; ?>" /> ) 
        <input type="text" name="F3Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone2']; ?>" /> - 
        <input type="text" name="F3Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F3Email" value="<?php echo $fields['F3Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "3") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F4FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F4MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F4LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F4FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F4SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN1']; ?>" /> - 
        <input type="text" name="F4SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN2']; ?>" /> - 
        <input type="text" name="F4SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F4DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F4DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F4DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F4Address" value="<?php echo $fields['F4Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F4City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F4State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F4Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F4Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone1']; ?>" /> ) 
        <input type="text" name="F4Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone2']; ?>" /> - 
        <input type="text" name="F4Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F4Email" value="<?php echo $fields['F4Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<div align="right"><input class="enrbutton" type="submit" name="submit" value="Continue" /></div>
</form>

这只需要 4 名运动员,而我需要它来捕捉 20 名运动员。有什么想法吗?假设有人注册了 20 名运动员,我被迫在 SESSION 中保留所有 200 多个元素。

I am building a PHP registration form which takes the following fields for up to 20 athletes:

First Name Middle Initial Last Name
Federation Number Address City State
Zip DOB SSN Phone Email

I am only through 7 of the fields for each fighter and my php file is very large (over 40kb). Is there ANY way to consolidate this code at all? I am also having to validate the information on each field (as I said - 20 athletes x 12 fields = 240 validations on a single page).

If I can send any further code let me know!

<form id="Form"  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="Form" onsubmit="return Enroll_Form_Validator(this)">
<p class="title">Your Fighters' Information</p>
<p>Please complete the following fields with your <span style="color:red;"> Fighters' Information</span> to continue your enrollment.</p>
<br />

<?php
    // if $errors is not empty, the form must have failed one or more validation 
    // tests. Loop through each and display them on the page for the user
    if (!empty($errors))
    {
      echo "<div class='error'>Please fix the following errors:\n<ul>";
      foreach ($errors as $error)
        echo "<li>$error</li>\n";

      echo "</ul></div>"; 
    }    
?>

<?php if ($_SESSION['Num_Fighters'] > "0") { ?>
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F1FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F1MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F1LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F1FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F1SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN1']; ?>" /> - 
        <input type="text" name="F1SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN2']; ?>" /> - 
        <input type="text" name="F1SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F1DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F1DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F1DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F1DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F1Address" value="<?php echo $fields['F1Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F1City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F1City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F1State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F1Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F1Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone1']; ?>" /> ) 
        <input type="text" name="F1Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone2']; ?>" /> - 
        <input type="text" name="F1Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F1Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F1Email" value="<?php echo $fields['F1Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "1") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F2FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F2MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F2LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F2FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F2SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN1']; ?>" /> - 
        <input type="text" name="F2SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN2']; ?>" /> - 
        <input type="text" name="F2SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F2DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F2DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F2DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F2DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F2Address" value="<?php echo $fields['F2Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F2City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F2City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F2State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F2Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F2Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone1']; ?>" /> ) 
        <input type="text" name="F2Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone2']; ?>" /> - 
        <input type="text" name="F2Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F2Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F2Email" value="<?php echo $fields['F2Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "2") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F3FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F3MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F3LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F3FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F3SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN1']; ?>" /> - 
        <input type="text" name="F3SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN2']; ?>" /> - 
        <input type="text" name="F3SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F3DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F3DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F3DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F3DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F3Address" value="<?php echo $fields['F3Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F3City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F3City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F3State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F3Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F3Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone1']; ?>" /> ) 
        <input type="text" name="F3Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone2']; ?>" /> - 
        <input type="text" name="F3Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F3Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F3Email" value="<?php echo $fields['F3Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<br />
<?php if ($_SESSION['Num_Fighters'] > "3") { ?>   
    <table class="demoTable">
    <tr>
      <td>First Name: </td>
        <td><input type="text" name="F4FirstName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4FirstName']; ?>" /></td>
    </tr>
    <tr>
      <td>Middle Initial: </td>
        <td><input type="text" name="F4MI" size="2" maxlength="1" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4MI']; ?>" /></td>
    </tr>
    <tr>
      <td>Last Name: </td>
        <td><input type="text" name="F4LastName" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4LastName']; ?>" /></td>
    </tr>
    <tr>
      <td>Federation No: </td>
        <td><input type="text" name="F4FedNum" maxlength="10" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4FedNum']; ?>" /></td>
    </tr>
    <tr>
      <td>SSN: </td>
        <td><input type="text" name="F4SSN1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN1']; ?>" /> - 
        <input type="text" name="F4SSN2" size="2" maxlength="2" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN2']; ?>" /> - 
        <input type="text" name="F4SSN3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4SSN3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Date of Birth</td>
        <td>
        <select name="F4DOB1">
            <option value="">Month</option> 
            <?php
                for ($i=1; $i<=12; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB1"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>            
        </select> / 
        <select name="F4DOB2">
            <option value="">Day</option>
            <?php
                for ($i=1; $i<=31; $i++)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB2"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select> / 
        <select name="F4DOB3">
            <option value="">Year</option>
            <?php
                for ($i=date('Y'); $i>=1900; $i--)
          {
            echo "<option value='$i'";
            if ($fields["F4DOB3"] == $i)
              echo " selected";
            echo ">$i</option>";
          }
          ?>
        </select>
        </td>
    </tr>
    <tr>
      <td>Address: </td>
        <td><input type="text" name="F4Address" value="<?php echo $fields['F4Address']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
        <td><input type="text" name="F4City" onkeyup="if(!this.value.match(/^([a-z]+\s?)*$/i))this.value=this.value.replace(/[^a-z ]/ig,'').replace(/\s+/g,' ')" value="<?php echo $fields['F4City']; ?>" /></td>
    </tr>
    <tr>
      <td>State: </td>
        <td><select name="F4State"><option value="">Choose a State</option><?php showOptionsDrop($states_arr, null, true); ?></select></td> 
    </tr>
    <tr>
      <td>Zip Code: </td>
        <td><input type="text" name="F4Zip" size="6" maxlength="5" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Zip']; ?>" /></td>
    </tr>
    <tr>
      <td>Contact Telephone No: </td>
        <td>( <input type="text" name="F4Phone1" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone1']; ?>" /> ) 
        <input type="text" name="F4Phone2" size="3" maxlength="3" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone2']; ?>" /> - 
        <input type="text" name="F4Phone3" size="4" maxlength="4" onkeyup="this.value=this.value.replace(/[^0-9]/ig, '')" value="<?php echo $fields['F4Phone3']; ?>" />
        </td>
    </tr>
    <tr>
      <td>Email:</td>
        <td><input type="text" name="F4Email" value="<?php echo $fields['F4Email']; ?>" /></td>
    </tr>    
    </table>
<?php } ?>
<div align="right"><input class="enrbutton" type="submit" name="submit" value="Continue" /></div>
</form>

This only goes through 4 athletes and I need it to capture 20. Any ideas? I am forced to keep all 200+ elements in SESSION assuming somebody enrolls 20 athletes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的旅程 2024-09-08 20:21:49

表格可能是一个真正的痛苦。我同意 Byron,但我想进一步指出,您不必使用 Zend 的 MVC 组件来使用 Zend 表单。通过将 Zend Form 插入到我的一些非 MVC 项目中,我已经取得了很多进展。

Forms can be a real pain. I'm with Byron, but I'd like to further point out that you don't have to use Zend's MVC components to use Zend Form. I've gotten a lot of mileage out plugging Zend Form into some of my non-mvc projects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文