I can't figure this out. I'm building a form with error check, and if there is an error it should return to form but with the allready correct fields still filled in. Normally I don't have any problems with this, but this form is a little different...

The form function:
PHP Code:
function addmembers(){
    
    global 
$prefix,$db
    global 
$err_fname0,$err_fname1
    global 
$err_lname0,$err_lname1;
    global 
$err_email0,$err_email1;
    global 
$fname0,$fname1,$lname0,$lname1,$email0,$email1;

echo 
'<form method="POST" action="users.php?site=addmembers">';
echo 
'<table><tr>
        <td>
            '
._MALE.' <input type="radio" name="sex0" value="male" checked />
            &nbsp;&nbsp;'
._FEMALE.' <input type="radio" name="sex0" value="female" />
        </td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._FIRST_NAME.':</td>
        <td><input name="fname[]" type="text" size="42" value="'
.$fname0.'"> '.$err_fname0.'</td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._LAST_NAMES.':</td>
        <td><input name="lname[]" type="text" size="42" value="'
.$lname0.'"> '.$err_lname0.'</td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._EMAIL.':</td>
        <td><input name="email[]" type="text" size="42" value="'
.$email0.'"> '.$err_email0.'</td>
    </tr>
    <tr>
        <td colspan="2"><br><div style="border-bottom:1px solid #669900;"></div><br></td>
    </tr>
    <tr>
        <td></td>
        <td>
            '
._MALE.' <input type="radio" name="sex1" value="male" checked />
            &nbsp;&nbsp;'
._FEMALE.' <input type="radio" name="sex1" value="female" />
        </td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._FIRST_NAME.':</td>
        <td><input name="fname[]" type="text" size="42" value="'
.$fname1.'"> '.$err_fname1.'</td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._LAST_NAMES.':</td>
        <td><input name="lname[]" type="text" size="42" value="'
.$lname1.'"> '.$err_lname1.'</td>
    </tr>
    <tr>
        <td align="right"><div align="right">'
._EMAIL.':</td>
        <td><input name="email[]" type="text" size="42" value="'
.$email1.'"> '.$err_email1.'</td>
    </tr>
    <tr>
        <td colspan="2"></td>
    </tr>
</table>'

And the formcheck:
PHP Code:
function do_addmembers(){
    
    global 
$prefix,$db
    global 
$err_fname0,$err_fname1
    global 
$err_lname0,$err_lname1;
    global 
$err_email0,$err_email1;
    global 
$fname0,$fname1,$lname0,$lname1,$email0,$email1;
    
    
$firstname $_POST['fname']; 
    
$lastname $_POST['lname'];
    
$email $_POST['email'];
    
$sex0 $_POST['sex0'];
    
$sex1 $_POST['sex1'];
    
    for (
$i 0$i count($firstname); $i++) {
        
        
$nemail $email[$i];
        
$nfname $firstname[$i];
        
$nlname $lastname[$i];
        
$nsex $_POST['sex'.$i.''];
        
        if((
$nfname || $nlname) && !$nemail){
                    
            
$reqmsg'<div style="padding:3px;color:#FFF;background-color:#F00;width:100%;text-align:center;">'._ONE_OR_MORE_EMAIL_INCORRECT.'</div>';
            
$err_email $reqmsg;
            
addmembers();
            exit();
            
        }
        
        
/// INSERT INTO DB /// 
Hope somebody can help...