示例#1
0
if (isset($_SESSION[Session::C_SESSION_USER])) {
    $session = new Session($_SESSION[Session::C_SESSION_USER], $_SESSION[Session::C_SESSION_PASS], $mySql);
}
if (!isset($session) or !$session->IsConnected()) {
    header('Location: index.php');
    exit;
}
?>
            <!-- MAIN SECTION -->
            <section class="main-section">
                <div class="small-12 columns">
                    <div class="row">
                        <h4>entraîneur - <?php 
$coach = new Coach();
if (isset($_POST["id"])) {
    $coach->initProperty($_POST["id"], $_POST["firstName"], $_POST["lastName"], $_POST["teamId"]);
    $coach->PageMode = $_POST["pageMode"];
    $coach->validate($mySql);
    if (!$coach->getHasError()) {
        if ($coach->PageMode == Constants::PAGE_MODE_EDIT) {
            $coach->update($mySql);
        } else {
            $coach->addNew($mySql);
        }
        header('Location: coach.php');
        exit;
    }
    echo $coach->getFullName();
} else {
    if (isset($_GET["id"])) {
        $coach->initDB($_GET["id"], $mySql);