here is the rest of the code
' <body>'.
' <table id="container" background="http://ufhl.theufhl.com/images/images/signupbk.gif"><tr><td style="padding:0 50px;">';
echo draw_form(array(
'id' => 'main_form',
'method' => 'post',
'action' => '/register_player.php?proc=New&post=yes',
'fields' => array(
array('label'=> 'First Name:', 'type'=>'text', 'name'=>'fname', 'required'=>1),
array('label'=> 'First Name Intial:', 'name'=>'fint', 'type'=>'text'),
array('label'=> 'Last Name:', 'type'=>'text', 'name'=>'lname', 'required'=>1),
array('label'=> 'Position:', 'type'=>'select', 'name'=>'position', 'fields'=>array(
array('label'=>' ', 'value'=>' '),
array('label'=>'Goalie', 'value'=>'G'),
array('label'=>'Defense', 'value'=>'D'),
array('label'=>'Center', 'value'=>'C'),
array('label'=>'Left Wing', 'value'=>'LW'),
array('label'=>'Right Wing', 'value'=>'RW')
)),
array('label'=> 'Number:', 'type'=>'text', 'name'=>'number'),
array('label'=> 'Date of Birth:', 'type'=>'text', 'name'=>'dob'),
array('label'=> 'Place of Birth:', 'type'=>'text', 'name'=>'pob'),
array('label'=> 'Nationality:', 'type'=>'select', 'name'=>'b_color', 'fields'=>array(
array('label'=>' ', 'value'=>' '),
array('label'=>'Canada', 'value'=>'can'),
array('label'=>'Ukraine', 'value'=>'ukr'),
array('label'=>'Czech', 'value'=>'chk'),
array('label'=>'Slovakia', 'value'=>'slo'),
array('label'=>'Germany', 'value'=>'ger'),
array('label'=>'Austria', 'value'=>'aus'),
array('label'=>'Swiss', 'value'=>'swi')
)),
array('label'=> 'Weight:', 'type'=>'text', 'name'=>'weight'),
array('label'=> 'Height:', 'type'=>'text', 'name'=>'height'),
array('label'=> 'Shoots:', 'type'=>'select', 'name'=>'shoots', 'fields'=>array(
array('label'=>' ', 'value'=>' '),
array('label'=>'Left', 'value'=>'Left'),
array('label'=>'Right', 'value'=>'Right')
)),
array('label'=> 'Email:', 'type'=>'text', 'name'=>'email', 'required'=>1),
array('label'=> 'Register', 'type'=>'submit', 'name'=>'submit'),
array('type'=>'hidden', 'name'=>'info', 'value'=>'75'),
array('type'=>'hidden', 'name'=>'salary', 'value'=>'20'),
array('type'=>'hidden', 'name'=>'terms', 'value'=>''),
array('type'=>'hidden', 'name'=>'status', 'value'=>'Rookie'),
array('type'=>'hidden', 'name'=>'captain', 'value'=>''),
array('type'=>'hidden', 'name'=>'injurystatus', 'value'=>''),
array('type'=>'hidden', 'name'=>'photo', 'value'=>''),
array('type'=>'hidden', 'name'=>'registered', 'value'=>''),
array('type'=>'hidden', 'name'=>'requested', 'value'=>'0')
)
));
echo ' </td></tr></table>'.
' </body>'.
'</html>';
}
function draw_form($o){
foreach($o['fields'] as $f){
if ($f['required']){
$req = '<span class="req"> *</span>';
$err = '<span class="err" id="error_'.$f['name'].'">You can\'t leave this empty.</span>';
$to_validate[] = '"'.$f['name'].'"';
} else {
$req = '';
$err = '';
}
if ($f['type'] == 'text'){
$result .= '<div class="line"><label for="'.$f['name'].'">'.$f['label'].$req.'</label><input type="text" id="field_'.$f['name'].'" name="'.$f['name'].'" />'.$err.'</div>';
} else if ($f['type'] == 'select'){
$result .= '<div class="line"><label for="'.$f['name'].'">'.$f['label'].$req.'</label><select id="field_'.$f['name'].'" name="'.$f['name'].'">';
foreach($f['fields'] as $fi){
$result .= '<option value="'.$fi['value'].'">'.$fi['label'].'</option>';
}
$result .= '</select>'.$err.'</div>';
} else if ($f['type'] == 'hidden'){
$result .= '<input type="hidden" name="'.$f['name'].'" value="'.$f['value'].'" />';
} else if ($f['type'] == 'submit'){
$result .= '<input type="submit" class="submit" name="'.$f['name'].'" value="'.$f['label'].'" />';
}
}
return '<form id="'.$o['id'].'" method="'.$o['method'].'" action="'.$o['action'].'" onsubmit="validate();return false;">'.
$result.
'</form>'.
'<script type="text/javascript">'.
' var to_validate = ['.implode(',', $to_validate).'];'.
' var len = to_validate.length;'.
' function validate(){'.
' if(len > 0){'.
' var req_count = 0;'.
' for (var i=0; i<len; i++){'.
' var el = document.getElementById("field_"+to_validate[i]);'.
' if (el.value == ""){'.
' el.style.borderColor = "red";'.
' document.getElementById("error_"+to_validate[i]).style.display = "inline";'.
' req_count++;'.
' } else {'.
' el.style.borderColor = "grey";'.
' document.getElementById("error_"+to_validate[i]).style.display = "none";'.
' }'.
' }'.
' if (req_count == 0) document.main_form.submit();'.
' }'.
' }'.
'</script>';
}
function db(){
$dbuser = "user-name";
$dbserver = "server-name";
$dbpass = "user-pass";
$dbname = "db-name";
$db_conn = mysql_connect($dbserver, $dbuser, $dbpass);
mysql_select_db($dbname);
return $db_conn;
}
?>