Hi there
I am making a player registration form for my website and when I submit the info it does everything it should, but when I goto the db it only inputs in the player id # no other info.
I have listed the code below and maybe someone could see what I have done wrong
<?
function register($pid,$teamid,$fname,$lname,$position,$number,$dob,$pob,$weight,$height,$salary,$terms,$info) {
include("config.php");
$open = mysql_connect($hostname,$user,$password);
mysql_select_db("$db",$open);
$teams = mysql_query("SELECT * FROM teams WHERE username = '$u'");
?>
<html>
<head>
<title>Add Player</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="includes/leaguestyle.css">
<style type="text/css">
<!--
a { color: #990000; text-decoration: none}
a:hover { color: #990000; text-decoration: underline}
-->
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="10" topmargin="10" marginwidth="0" marginheight="0">
<?
if($add == "yes") {
if($fname == "" || $lname == "" || $teamid == "") {
echo "<p class=warning align=center>NO NEW PLAYER ADDED:<br>YOU DID NOT COMPLETE THE FORM.</p>\n\r
<p class=header align=center>GO <a href='javascript:history.go(-1)'><u>BACK</u></a> AND TRY AGAIN.</p>";
} elseif($requested == 1) {
$sql = "UPDATE players SET requested = '1' WHERE id = '$pid'";
$done = mysql_query($sql);
if(!$done) {
echo mysql_errno().": ".mysql_error()."<br>";
exit;
}
}
}
if(!$pid) {
$sql = "INSERT INTO players VALUES ";
$sql .= "('NULL','$lname1','$fname1','$teamid','$position1',";
$sql .= "'$number1','$dob','$pob','$weight','$height','$info','$salary','$terms','','1','0')";
$done = mysql_query($sql);
if(!$done) { echo mysql_errno().": ".mysql_error()."<br>"; }
}
$st = "";
//GET TEAM NAME
$result_tn = mysql_query("SELECT id,name,division FROM teams WHERE name != 'admin' AND name != 'divadmin' ORDER BY name");
$selectteam_name = mysql_result($result_tn,0,"name");
$counter = 0;
$total_rows = mysql_numrows($result_tn);
while($counter < $total_rows) {
$tname = mysql_result($result_tn,$counter,"name");
$tid = mysql_result($result_tn,$counter,"id");
$divn = mysql_result($result_tn,$counter,"division");
$result_td = mysql_query("SELECT name FROM divisions WHERE id = '".$divn."'");
$dname = mysql_result($result_td,0,"name");
if ($hname != "admin") {
$teamlist .= "
<option value=\"".$tid."\">".$tname." - ".$dname."</option>";
}
$counter++;
}
$form = "
<p align=center class=\"header\">Add Player to League</p>
<form name='calform' method='post' action='/'>
<input type='hidden' name='add' value='yes'>";
if(!$pid) {
$form .= "
<table border=0 cellpadding=8 cellspacing=0 align=center width='100%'>
<tr><td bgcolor='#efefef' class='table_header'>First Name:*</td>
<td bgcolor='#efefef' class='table_text' colspan='3'>
<input class='table_text' type=text name=\"fname\">
</td>
</tr>
<tr>
<td class='table_header' bgcolor='#ffffff'>Last Name:*</td>
<td class='table_text' bgcolor='#ffffff' colspan='3'>
<input class='table_text' type=text name=\"lname\">
</td>
</tr>";
} else {
$result_pn = mysql_query("SELECT fname,lname FROM players WHERE id = '".$pid."'");
$fname = mysql_result($result_pn,0,"fname");
$lname = mysql_result($result_pn,0,"lname");
$form .= "
<input type='hidden' name='pid' value='".$pid."'>
<input type='hidden' name='fname' value='".$fname."'>
<input type='hidden' name='lname' value='".$lname."'>
<input type='hidden' name='requested' value='1'>
<table border=0 cellpadding=8 cellspacing=0 align=center width='100%'>
<tr>
<td class='table_header' bgcolor='#ffffff'>Player Name:</td>
<td class='table_text' bgcolor='#ffffff' colspan='3'>"
.$fname." ".$lname."
</td>
</tr>";
}
if($st == "") {
$form .= "
<tr>
<td bgcolor='#efefef' class=table_header>Team:</td>
<td class='table_text' bgcolor='#efefef'>
<select name='teamid' class='table_text'>
<option value=\"\"></option>".$teamlist."</select>
</td>
</tr>";
} else {
$form .= "<input type=\"hidden\" name=\"teamid\" value=\"".$st."\">";
}
$form .= "
<tr>
<td class=table_header bgcolor='#ffffff'>Position:</td>
<td class='table_text' bgcolor='#ffffff'>
<select name='position' class='table_text'>
<option value=\"\"></option>
<option value=\"G\">Goalie</option>
<option value=\"D\">Defense</option>
<option value=\"C\">Center</option>
<option value=\"LW\">Left Wing</option>
<option value=\"RW\">Right Wing</option>
</select>
</td>
</tr>
<tr>
<td class=table_header bgcolor='#efefef'>Number:</td>
<td class='table_text' bgcolor='#efefef'>
<input class='table_text' type=text name=\"number\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#ffffff'>Dob:</td>
<td class='table_text' bgcolor='#ffffff'>
<input class='table_text' type=text name=\"dob\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#efefef'>Pob:</td>
<td class='table_text' bgcolor='#efefef'>
<input class='table_text' type=text name=\"pob\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#ffffff'>Weight:</td>
<td class='table_text' bgcolor='#ffffff'>
<input class='table_text' type=text name=\"weight\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#efefef'>Height:</td>
<td class='table_text' bgcolor='#efefef'>
<input class='table_text' type=text name=\"height\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#ffffff'>Salary:</td>
<td class='table_text' bgcolor='#ffffff'>
<input class='table_text' type=text name=\"salary\">
</td>
</tr>
<tr>
<td class=table_header bgcolor='#efefef'>Player Information:</td>
<td class='table_text' bgcolor='#efefef'>
<textarea class='table_text' name='info' cols='40' rows='5'></textarea></td>
</tr>
<tr>
<td bgcolor='#efefef' colspan=\"2\" align=\"center\">
<input class=\"button\" type=\"submit\" name=\"Submit\" value=\"Add Player!\">
<input class=\"button\" type=\"button\" value=\"Cancel\" onClick=\"self.close()\">
</td>
<tr>
</table></form>";
echo $form;
}
?>
</body>
</html>
thanks very much
mike