}
$cancelOK = false;
// whether the record was successfully canceled
if ($_POST['isSubmit'] == 'yes') {
    // gets the form field values
    $fldSubId = intval($_POST['fldSubId']);
    $fldReason = mysql_real_escape_string($_POST['fldReason']);
    $fldOtherReason = mysql_real_escape_string($_POST['other']);
    // tbl_college_subscription data
    $new_fldActive = 0;
    $new_fldCancelDate = date('Y-m-d');
    $new_fldCancelReason = $fldReason;
    $new_fldCancelReasonOther = $fldOtherReason;
    // tbl_college_coach data
    $new_fldSubscribe = $subsCount > 1 ? 1 : 0;
    $new_fldCancelCount = $fldCancelCount + 1;
    // updates the record in tbl_college_subscription
    $data = array('fldActive' => $new_fldActive, 'fldCancelDate' => $new_fldCancelDate, 'fldCancelReason' => $new_fldCancelReason, 'fldCancelReasonOther' => $new_fldCancelReasonOther);
    $rows = $db->updateRec(TBL_COLLEGE_SUBSCRIPTION, $data, 'fldId=' . $fldSubId);
    // updates the record in tbl_college_coach_register
    $data = array('fldSubscribe' => $new_fldSubscribe, 'fldCancelCount' => $new_fldCancelCount);
    $rows = $db->updateRec(TBL_COLLEGE_COACH_REGISTER, $data, 'fldId=' . $fldCoach);
    $cancelOK = true;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>College Prospect Network</title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
//for common function
include_once "inc/page.inc.php";
include_once "inc/config.inc.php";
//for paging
$func = new COMMONFUNC();
$db = new DB();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Comments From My Coach</title>
		<META NAME="Keywords" CONTENT="My Account">
		<META NAME="Description" CONTENT="My Account">
		<link href="css/style.css" rel="stylesheet" type="text/css" />
		<script language="Javascript" src="javascript/functions.js"></script>
		<script language="JavaScript" type="text/JavaScript">
		
		function refreshParent() {
                window.opener.location.href = window.opener.location.href;
                if(window.opener.progressWindow) {
                    window.opener.progressWindow.close()
                }
                window.close();
            }
            
            function validate() {
                var error_msg = "";    
                //Check Values
                 if(trimString(document.frmSubmit.fldDivision.value) == "select") {
                    error_msg += "Please Select the Athlete's Projected Division. \n";
            $coupon = mysql_query("select * from tbl_cupon where cpn_number='" . $_POST['fldCouponNumber'] . "' AND status='1'");
            $re = mysql_fetch_array($coupon);
            if ($_POST['fldCouponNumber'] == $re['cpn_number']) {
                $fldprice = $fldprice - $re['amount'];
                $coupondiscount = $re['amount'];
            }
            $fldpaymentstatus = "INCOMPLETE";
            ##INSERT Enent###
            #######################################
            $strDataArr = array('fldFirstName' => $func->input_fun($_POST['fldFirstName']), 'fldLastName' => $func->input_fun($_POST['fldLastName']), 'fldAddress' => $func->input_fun($_POST['fldBSAddress']), 'fldCity' => $func->input_fun($_POST['fldBSCity']), 'fldState' => $func->input_fun($_POST['fldBSState']), 'fldZipCode' => $func->input_fun($_POST['fldBSZipCode']), 'fldPhone' => $func->input_fun($_POST['fldPhone']), 'fldEmail' => $func->input_fun($_POST['fldEmail']), 'fldSpecialEvent' => $func->input_fun($_POST['fldSpecialEvent']), 'fldReferredBy' => $func->input_fun($_POST['fldReferredBy']), 'fldClass' => $func->input_fun($_POST['fldClass']), 'fldPrimaryPosition' => $func->input_fun($_POST['fldPrimaryPosition']), 'fldSecondaryPosition' => $func->input_fun($_POST['fldSecondaryPosition']), 'fldHSCoachName' => $func->input_fun($_POST['fldHSCoachName']), 'fldSchool' => $func->input_fun($fldSchool), 'fldOthers' => $func->input_fun($_POST['txtfldName']), 'Address' => $func->input_fun($Address), 'City' => $func->input_fun($City), 'State' => $func->input_fun($State), 'Zipcode' => $func->input_fun($Zipcode), 'fldAAUCoachName' => $func->input_fun($_POST['fldAAUCoachName']), 'AAUOther' => $func->input_fun($_POST['txtfldAAUName']), 'HS_AAU_Team' => $func->input_fun($fldAAUSchool), 'AAUAddress' => $func->input_fun($fldAAUAddress), 'AAUCity' => $func->input_fun($fldAAUCity), 'AAUState' => $func->input_fun($fldAAUState), 'AAUZipCode' => $func->input_fun($fldAAUZipcode), 'fldCouponNumber' => $func->input_fun($_POST['fldCouponNumber']), 'fldTransportation' => $func->input_fun($fldTransportation), 'fldTranscript' => $newname, 'fldprice' => $fldprice, 'fldpaymentstatus' => $fldpaymentstatus, 'fldAddDate' => date("y-m-d"));
            //print_r($strDataArr);
            $debugstep = 2;
            //Insert Data - Get NewUserID
            if (isset($_REQUEST['fld_id']) && $_REQUEST['fld_id'] != '') {
                $where_reg_update = "fldId = " . $_REQUEST['fld_id'];
                $result = $db->updateRec(TBL_SPECIAL_EVENT_REGISTER, $strDataArr, $where_reg_update);
                $NewUserId = $_SESSION['fld_id'];
            } else {
                $NewUserId = $db->insertRec(TBL_SPECIAL_EVENT_REGISTER, $strDataArr);
            }
            $error_msg = "Thankyou for Register with Our Event";
            $_SESSION['fld_id'] = $NewUserId;
            $debugstep = 3;
            ?>

	  <script> window.location.href='Event_confirmation.php';</script>
	  <?php 
            exit;
        }
    }
    ?>
//for common function
include_once "inc/page.inc.php";
session_start();
if ($_SESSION['mode'] == "" or $_SESSION['FRONTEND_USER'] == "") {
    header("Location:login.php");
}
//echo print_r($_SESSION);die();
//for paging
$func = new COMMONFUNC();
$db = new DB();
$flag = 0;
#### DEMO MODE SWITCHER (user san_jac) ####
if ($_POST['trial']) {
    $where = "fldId='" . $_POST['userid'] . "'";
    $strDataArr = array('fldSubscribe' => 2);
    $db->updateRec(TBL_COLLEGE_COACH_REGISTER, $strDataArr, $where);
}
if ($_POST['subscription']) {
    $where = "fldId='" . $_POST['userid'] . "'";
    $strDataArr = array('fldSubscribe' => 1);
    $db->updateRec(TBL_COLLEGE_COACH_REGISTER, $strDataArr, $where);
}
if ($_POST['inactive']) {
    $where = "fldId='" . $_POST['userid'] . "'";
    $strDataArr = array('fldSubscribe' => 0);
    $db->updateRec(TBL_COLLEGE_COACH_REGISTER, $strDataArr, $where);
}
//Global Vars
$UserID = "";
$UserType = $_SESSION['mode'];
$NetworkReq_Pending = "";
    }
    if ($_POST['fldSchool'] != "others") {
        if ($fldSchool == 'others') {
            $String_Delete_Query = "delete from " . TBL_HS_AAU_TEAM_OTHER . " where  fldUserId =" . $fldAthleteid;
            $db->query($String_Delete_Query);
        }
    }
    if ($_POST['fldSchool'] == "others") {
        $whereClause_team = "fldSchoolname='" . $func->input_fun($_POST['txtfldName']) . "'";
        $flagss = 0;
        if ($db->MatchingRec(TBL_HS_AAU_TEAM, $whereClause_team) > 0) {
            #user Username already exists
            $strDataArr_other = array('fldCoachName' => $func->input_fun($_POST['txtfldAddress']), 'fldCoachPhone' => $func->input_fun($_POST['txtfldContactInfo']));
            $strDataArr_team = array('fldCoachPhone' => $func->input_fun($_POST['txtfldAddress']), 'fldStatus' => "DEACTIVE");
            $where_team_other_Update = 'fldUserId =' . $fldAtheleteid;
            $db->updateRec(TBL_HS_AAU_TEAM_OTHER, $strDataArr_other, $where_team_other_Update);
            $where_team_Update = "fldSchoolname='" . $func->input_fun($_POST['txtfldName']) . "'";
            $db->updateRec(TBL_HS_AAU_TEAM, $strDataArr, $where_team_Update);
            $flagss++;
        }
        if ($flagss == 0) {
            $strDataArr_other = array('fldName' => $func->input_fun($_POST['txtfldName']), 'fldCoachName' => $func->input_fun($_POST['txtfldAddress']), 'fldCoachPhone' => $func->input_fun($_POST['txtfldContactInfo']), 'fldUserId' => $fldAtheleteid);
            $strDataArr_team = array('fldSchoolname' => $func->input_fun($_POST['txtfldName']), 'fldCoachPhone' => $func->input_fun($_POST['txtfldContactInfo']), 'fldStatus' => "DEACTIVE");
            $db->insertRec(TBL_HS_AAU_TEAM_OTHER, $strDataArr_other);
            $db->insertRec(TBL_HS_AAU_TEAM, $strDataArr_team);
        }
    }
    $db->updateRec(TBL_ATHELETE_REGISTER, $strDataArr, $where);
    #redirect to listing page on successfull updation
    header("Location: myaccount.php?page=" . $_REQUEST['page'] . "&msg=Profile successfully updated.");
}
<!--

function refreshParent() {

  window.opener.location.href = window.opener.location.href;



  if (window.opener.progressWindow)

		

 {

    window.opener.progressWindow.close()

  }

  window.close();

}

</script>

</head>

<body>


         //append cpn_AthleteID- to filename
         $video = $flvobj->convert_video($_FILES['fldVideo']);
         //Check if Video has problems
         if ($video == '') {
             $error_msg = 'Error occurred during Upload, please re-try using a smaller video size.';
             $flag++;
         }
     }
     //Update DB Record
     ///////////
     $videoStatus = $func->input_fun($_POST['fldStatus']);
     if ($videoStatus == 1) {
         //Disable all other videos for this user
         $where = "fldAthleteId=" . $db1->f('fldId');
         $strDataArr = array('fldStatus' => 0);
         $db->updateRec(TBL_ATHLETE_VIDEO, $strDataArr, $where);
     }
     $where = "fldId=" . $fldId;
     $strDataArr = array('fldTitle' => $func->input_fun($_POST['fldTitle']), 'fldVideo' => $video, 'fldStatus' => $func->input_fun($_POST['fldStatus']));
     $db->updateRec(TBL_ATHLETE_VIDEO, $strDataArr, $where);
     //Check if Update has problems
     // if ($VideoID == '') {
     // $error_msg = 'Error occurred during Update, please re-try';
     // $flag++;
     // }
 }
 //End flag check
 if ($error_msg == "") {
     //No Errors
     header("Location:Video-List.php?msg=Game Tape successfully updated.");
 } else {
}
//for paging
$func = new COMMONFUNC();
$db = new DB();
$flag = 0;
$error_msg = '';
if ($_POST['isSubmit'] == 'save') {
    if ($_SESSION['FRONTEND_USER'] != "") {
        $whereClause = "fldUsername='******'FRONTEND_USER'] . "' and fldPassword ='******'oldpassword']) . "'";
        if ($db->MatchingRec(TBL_HS_AAU_COACH, $whereClause) == 0) {
            $error_msg = 'Old Password incorrect, please re-try';
        } else {
            if ($error_msg == '') {
                $strDataArr = array('fldPassword ' => $func->input_fun($_POST['newpassword']));
                $where = "fldUsername='******'FRONTEND_USER'] . "'";
                $db->updateRec(TBL_HS_AAU_COACH, $strDataArr, $where);
                ${$_SESSION}['FRONTEND_USER'] = "";
                header("Location: Coachchangepassword.php&msg=Password successfully updated.");
            }
        }
    }
    //this section is use to filup the value after erro message.
    if ($error_msg != "") {
        $oldpassword = $_REQUEST['oldpassword'];
        $newpassword = $_REQUEST['newpassword'];
        $confirmnewpassword = $_REQUEST['confirmnewpassword'];
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 if ($_POST['fldSchool'] == "other") {
     ##########################################
     ### Insert Custom College ###
     ##########################################
     //Get Lattitude & Longitude
     $Zipcode_lat_lon = $func->getLatLong($_POST['fldZipcode'], MAPS_APIKEY);
     //Build Insert Data
     $fldStatus = "ACTIVE";
     $strDataArr_school = array('fldSchoolname' => $func->input_fun($_POST['txtfldName']), 'fldAddress' => $func->input_fun($_POST['fldAddress']), 'fldCity' => $func->input_fun($_POST['fldCity']), 'fldState' => $func->input_fun($_POST['fldState']), 'fldZipcode' => $func->input_fun($_POST['fldZipcode']), 'fldStatus' => $fldStatus, 'fldLatitude' => $Zipcode_lat_lon['Latitude'], 'fldLongitude' => $Zipcode_lat_lon['Longitude'], 'fldAdminApproved' => 0, 'fldAddByAthleteUsername' => $_POST['fldUsername'], 'fldAddDate' => date("y-m-d"));
     //Insert & Set CollegeSchoolId
     $NewSchoolId = $db->insertRec(TBL_HS_AAU_TEAM, $strDataArr_school);
     $HighSchoolId = $NewSchoolId;
     //Update  User's fldSchool column
     $strDataArr_schoolreg_update = array('fldSchool' => $HighSchoolId);
     $where_schoolreg_update = "fldId = " . $NewUserId;
     $db->updateRec(TBL_ATHELETE_REGISTER, $strDataArr_schoolreg_update, $where_schoolreg_update);
     ################# Insert Custom College #################
 }
 // Send email to coach for Approval
 if ($_POST['fldSchool'] != "other") {
     //User Selected School
     $schoolid = $func->input_fun($_POST['fldSchool']);
     $sportid = $func->input_fun($_POST['fldSport']);
     $emailarr = array();
     $selquery = 'select first.fldId,first.fldEmail as fldEmail,first.fldName as name,first.fldLastName as lname,first.fldUsername as HSCoachUsername,first.fldPassword as HSCoachPassword from ' . TBL_HS_AAU_COACH . ' first,' . TBL_HS_AAU_COACH_SPORT_POSITION . ' second  where second.fldCoachNameId = first.fldId and second.fldSportId =' . $sportid . ' and first.fldSchool =' . $schoolid;
     $db->query($selquery);
     $db->next_record();
     if ($db->num_rows() > 0) {
         for ($i = 0; $i < $db->num_rows(); $i++) {
             $emailarr[] = $func->output_fun($db->f('fldEmail'));
             $name = $func->output_fun($db->f('name'));
 if ($_POST['fldSchool'] == "other") {
     ##########################################
     ### Insert Custom High School  ###
     ##########################################
     //Get Lattitude & Longitude
     $Zipcode_lat_lon = $func->getLatLong($_POST['fldZipcode'], MAPS_APIKEY);
     //Build Insert Data
     $fldStatus = "ACTIVE";
     $strDataArr_school = array('fldSchoolname' => $_POST['txtfldName'], 'fldAddress' => $_POST['fldAddress'], 'fldCity' => $_POST['fldCity'], 'fldState' => $_POST['fldState'], 'fldZipcode' => $_POST['fldZipcode'], 'fldStatus' => $fldStatus, 'fldLatitude' => $Zipcode_lat_lon['Latitude'], 'fldLongitude' => $Zipcode_lat_lon['Longitude'], 'fldAdminApproved' => 0, 'fldAddByCoachUsername' => $_POST['fldUsername'], 'fldAddDate' => date("y-m-d"));
     //Insert & Set CollegeSchoolId
     $NewSchoolId = $db->insertRec(TBL_HS_AAU_TEAM, $strDataArr_school);
     $HighSchoolId = $NewSchoolId;
     //Update  User's fldSchool column
     $strDataArr_schoolreg_update = array('fldSchool' => $HighSchoolId);
     $where_schoolreg_update = "fldId = " . $NewUserId;
     $db->updateRec(TBL_HS_AAU_COACH, $strDataArr_schoolreg_update, $where_schoolreg_update);
     ################# Insert Custom High School  #################
 }
 //Insert Sport Positions
 for ($n = 0; $n < $_POST['currentrow']; $n++) {
     if ($n == 0) {
         $strDataArrw = array('fldSportId' => $func->input_fun($_POST['fldSport']), 'fldPosition' => $func->input_fun($_POST['fldPosition']), 'fldCoachNameId' => $coach_max_id);
     } else {
         $strDataArrw = array('fldSportId' => $func->input_fun($_POST['fldSport' . $n]), 'fldPosition' => $func->input_fun($_POST['fldPosition' . $n]), 'fldCoachNameId' => $coach_max_id);
     }
     $db->insertRec(TBL_HS_AAU_COACH_SPORT_POSITION, $strDataArrw);
 }
 $_SESSION['FRONTEND_USER'] = $func->input_fun($_POST['fldUsername']);
 $_SESSION['EMAIL'] = $func->input_fun($_POST['fldEmail']);
 $_SESSION['Coach_id'] = $NewUserId;
 $_SESSION['mode'] = 'coach';
     ### Insert Custom College ###
     ##########################################
     //Get Lattitude & Longitude
     $Zipcode_lat_lon = $func->getLatLong($_POST['fldZipCode'], MAPS_APIKEY);
     //Build Insert Data
     $strDataArr_college = array('fldName' => $func->input_fun($_POST['txtfldName']), 'fldAddress' => $func->input_fun($_POST['fldAddress']), 'fldCity' => $func->input_fun($_POST['fldCity']), 'fldState' => $func->input_fun($_POST['fldState']), 'fldZipCode' => $func->input_fun($_POST['fldZipCode']), 'fldStatus' => 1, 'fldDivison' => $func->input_fun($_POST['fldDivison']), 'fldLatitude' => $Zipcode_lat_lon['Latitude'], 'fldLongitude' => $Zipcode_lat_lon['Longitude'], 'fldAdminApproved' => 0, 'fldAddByCollegeUsername' => $_POST['fldUserName'], 'fldAddDate' => date("y-m-d"));
     //Insert & Set CollegeSchoolId
     $NewCollegeSchoolId = $db->insertRec(TBL_COLLEGE, $strDataArr_college);
     $CollegeSchoolId = $NewCollegeSchoolId;
     //Insert Tester
     #$strDataArrw = array('fldName' => $CollegeSchoolId, 'fldAddress' => $NewUserId,);
     #$db -> insertRec(TBL_OTHER, $strDataArrw);
     //Update College User's fldCollegename
     $strDataArr_collegereg_update = array('fldCollegename' => $CollegeSchoolId);
     $where_collegereg_update = "fldId = " . $NewUserId;
     $db->updateRec(TBL_COLLEGE_COACH_REGISTER, $strDataArr_collegereg_update, $where_collegereg_update);
     ################# Insert Custom College #################
 }
 ###################################################
 #Email Admin COLLEGE COACH Registration Notification
 ###################################################
 if ($_POST['fldCollegename'] == "other") {
     $subjectStre = "[CPN] - New College Coach Registration + New College";
     $bodyStre = "New College Coach Registration + New College<br />";
 } else {
     $subjectStre = "[CPN] - New College Coach Registration";
     $bodyStre = "New College Coach Registration:<br />";
 }
 #all user types
 $bodyStre .= "<br /><b>Status:</b> Active - 5 Day Trial Period";
 $bodyStre .= "<br /><b>College User Id:</b> " . $NewUserId;