Okay I have this form that when submitted is supposed to updated a team profile in a mysql database.
When I click submit it just refreshes the page, and doesn't work.
Here is my code (part1):
<?
##### Handle Registration Data
if (isset($_POST['submit']))
{
$message=NULL; // Empty variable
$xTeamId=$_POST['xTeamId'];
///// Check for City
if (empty($_POST['xCity']))
{
$xCity=FALSE;
$message .='You forgot to enter the team city.<br>';
} else {
$xCity=escape_data($_POST['xCity']);
}
///// Check for Symbol
if (empty($_POST['xSymbol']))
{
$xSymbol=FALSE;
$message .='You forgot to enter the team symbol/mascot.<br>';
} else {
$xSymbol=escape_data($_POST['xSymbol']);
}
///// Check for Abbreviation
if (empty($_POST['xAbv']))
{
$xAbv=FALSE;
$message .='You forgot to enter the team abbreviation.<br>';
} else {
$xAbv=escape_data($_POST['xAbv']);
}
///// Check for Website
if (empty($_POST['xWebsite']))
{
$xWebsite=FALSE;
$message .='You forgot to enter the team website.<br>';
} else {
$xWebsite=escape_data($_POST['xWebsite']);
}
///// Check for Conference
if (empty($_POST['xConf'])){$xConf=NULL;} else {$xConf=escape_data($_POST['xConf']);}
///// Check for Division
if (empty($_POST['xDiv'])){$xDiv=NULL;} else {$xDiv=escape_data($_POST['xDiv']);}
///// Check for Regular Season Games Played
if (empty($_POST['xRSGP'])){$xRSGP=NULL;} else {$xRSGP=escape_data($_POST['xRSGP']);}
///// Check for Regular Season Win
if (empty($_POST['xRSW'])){$xRSW=NULL;} else {$xRSW=escape_data($_POST['xRSW']);}
///// Check for Regular Season Loss
if (empty($_POST['xRSL'])){$xRSL=NULL;} else {$xRSL=escape_data($_POST['xRSL']);}
///// Check for Regular Season Tie
if (empty($_POST['xRST'])){$xRST=NULL;} else {$xRST=escape_data($_POST['xRST']);}
///// Check for Regular Season Overtime Loss
if (empty($_POST['xRSOTL'])){$xRSOTL=NULL;} else {$xRSOTL=escape_data($_POST['xRSOTL']);}
///// Check for Playoff Games Played
if (empty($_POST['xPOGP'])){$xPOGP=NULL;} else {$xPOGP=escape_data($_POST['xPOGP']);}
///// Check for Playoff Win
if (empty($_POST['xPOW'])){$xPOW=NULL;} else {$xPOW=escape_data($_POST['xPOW']);}
///// Check for Playoff Loss
if (empty($_POST['xPOL'])){$xPOL=NULL;} else {$xPOL=escape_data($_POST['xPOL']);}
} else {
$xCity=null;$xSymbol=null;$xAbv=null;$xWebsite=null;$xConf=null;$xDiv=null;$xTeamId=null;
}
##x
##### Insert Registration Data into DB, if everything checks out
if ($xCity && $xSymbol && $xAbv && $xWebsite && $xConf && $xDiv && $xTeamId)
{
///// Make the query
$query="UPDATE
nhl_teams
SET
team_city='$xCity',
team_symbol='$xSymbol',
team_abv='$xAbv',
team_website='$xWebsite',
team_conf='$xConf',
team_div='$xDiv',
team_season_gp='$xRSGP',
team_season_w='$xRSW',
team_season_l='$xRSL',
team_season_t='$xRST',
team_season_otl='$xRSOTL',
team_playoff_gp='$xPOGP',
team_playoff_w='$xPOW',
team_playoff_l='$xPOL'
WHERE
team_id='$xTeamId'";
$result=mysql_query($query); ///// Run the query
if ($result) ///// If the query ran OKAY
{
///// Set redirect
$message.="Changes to team (".$xCity." ".$xSymbol.") have been successfully updated.";
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/view_team.php?hub=nhl&team=$xTeamId&message=$message");
exit(); ///// Quit the script
} else { ///// If the query had errors
$message.='Changes could not be made due to a system error.<br>';
$message.='We apologize for any inconvenience.<br>';
$message.=mysql_error();
}
}
##x
$_site_Page='Edit Team'; ///// Title
require(INC_DIR.INC_PREFIX."header.php"); ///// Header including top navigation
$query="SELECT * FROM nhl_teams WHERE team_id=".$_GET['team'];
$result=@mysql_query($query); ///// Run the query
$row=mysql_fetch_array($result, MYSQL_NUM); ///// Return a record if exists
?>