0 || strlen($_GET[gameID])>0)
{
$gameID = $_POST[gameID] ?: $_GET[gameID];

$qry = $wpdb->prepare(“select LM.date as ‘gameDate’, Home.title as ‘homeTeam’, Home.id as ‘homeID’,Away.title as ‘awayTeam’,Away.id as ‘awayID’,LL.title as ‘division’, LL.id as ‘divisionID’, MF.id as ‘fieldID’, MF.fieldName as ‘fieldName’,LM.location as ‘fieldExtra’,LM.season as ‘season’ from 4Ao_leaguemanager_matches LM join wp_mysl_matches MM on LM.id = MM.id join 4Ao_leaguemanager_teams Home on Home.id = LM.home_team join 4Ao_leaguemanager_teams Away on Away.id = LM.away_team join 4Ao_leaguemanager_leagues LL on LL.id = LM.league_id left outer join wp_mysl_fields MF on MF.id = MM.fieldID where LM.id = %d LIMIT 1″,$gameID);

$singlerow = $wpdb->get_row( $qry, ARRAY_A, 0 );

$homeID = $singlerow[homeID];
$homeTitle = $singlerow[homeTeam];
$awayID = $singlerow[awayID];
$awayTitle = $singlerow[awayTeam];
$divisionID = $singlerow[divisionID];
$divisionTitle = $singlerow[division];
$fieldID = $singlerow[fieldID];
$fieldName = $singlerow[fieldName];
$fieldExtra = $singlerow[fieldExtra];
$gameDate = $singlerow[gameDate];
$parsedGameDate = date_parse($gameDate);
$season = $singlerow[season];

if(strlen($_POST[newTime]) > 0)
{
$parsedPostTime = date_parse($_POST[newTime]);

$parsedTime = $parsedPostTime[hour].”:”.$parsedPostTime[minute];
}
else
{
$parsedTime = $parsedGameDate[hour].”:”.$parsedGameDate[minute];
}
$defaultField = $wpdb->get_var( $wpdb->prepare (‘select fieldID from wp_mysl_teams where id = %d’,$homeID));

if(strlen($_POST[newFieldID]))
{
$newFieldID = $_POST[newFieldID];
}
else
{
$newFieldID = $fieldID;
}

}

if( ($now < $from) && ( $divisionID != 77) ) : echo("Game Change Request Form is currently disabled during the Online Scheduling Period. To schedule your games, please go through the Schedules and Standings section."); else : if(isset($_POST['validated'])) { $validated = $_POST['validated']; } if($_POST['validateBTN']) { $qry = $wpdb->prepare( “select id,hash from wp_mysl_teams where ( id = %d or id = %d ) and teamPIN = %d LIMIT 1”,$homeID,$awayID, $_POST[‘teamPIN’] );

$therow = $wpdb->get_row( $qry );

if(!$therow)
{
echo(“I’m sorry, that number does not check out. If you are repeatedly unable to validate, please contact your Club representative who can lookup your code.”);
}
else
{
$validated = $therow->hash;

$requestingTeam = $therow->id;
}
}

if(
$_POST[submit]
&&
isset($_POST[requestorEmail])
&&
(strpos($_POST[requestorEmail],’@’) == true)
&&
(strpos($_POST[requestorEmail],’.’) == true)
&&
isset($_POST[gameID])
&&
$_POST[reasonForChange] != “Please Choose”
)
{

$qry = $wpdb->prepare( “select id from wp_mysl_gameChanges where gameID = %d and submitterEmail = %s and reasonForChange = %s and newFieldID = %d and newFieldExtra = %s and newDate = %s and newDateTime = %s and myslApproved is NULL and myslDenied is NULL”,
$_POST[gameID],
$_POST[requestorEmail],
$_POST[reasonForChange],
$_POST[newFieldID],
$_POST[fieldExtra],
$_POST[newDate],
$_POST[newTime]
);

$exists = $wpdb->get_var( $qry );

if(!$exists)
{
$qry = $wpdb->prepare(“insert into wp_mysl_gameChanges(gameID, submitterEmail, reasonForChange, newFieldID, newFieldExtra, newDate, newDateTime, dateSubmitted, requestingTeamName) values (%d,%s,%s,%d,%s,%s,%s,%s,%s)”,
$_POST[gameID],
$_POST[requestorEmail],
$_POST[reasonForChange],
$_POST[newFieldID],
$_POST[fieldExtra],
$_POST[newDate],
$_POST[newTime],
date(‘Y-m-d H:i:s’),
$_POST[requestingTeam]
);

$result = $wpdb->query($qry);
}
else
{
$result = true;
}

if($result === true)
{
?>

Game change submitted successfully! MYSL has been notified of your request.

Click here to go to the administrative dashboard.’,
$headers
);
}
}

}
else
{
if ($_POST[‘validated’] || $validated)
{
?>

Team Requesting Change* Please enter the name of the Requesting Team.“);
}
?> Requestor’s Email* 0 && !$_POST[‘validateBTN’])
{
echo(“Please Supply an Email address.“);
}
else if ($_POST[requestorEmail] && (strpos($_POST[requestorEmail],’@’) == false))
{
echo(“Please Supply a valid email address.“);
}
else if ($_POST[requestorEmail] && (strpos($_POST[requestorEmail],’.’) == false))
{
echo(“Please Supply a valid email address.“);
}

?> Division* Please enter the division name.“);
}
?> Game ID Number* Please enter the Game ID number.“);
}
?> Home Team* Please enter the Home Team Name.“);
}
?> Away Team* Please enter the Away Team Name.“);
}
?> Current Field Current Date & Time Reason For Change* Please choose a reason for this request.“);
}

?> New Field (if any)

New Date (if any) New Time (if any) * indicates a required field.

In order to proceed to the game change form for game number , in the division, please enter either a valid reg code for either the home () or away () team.