<?php

require_once "views/GeneralView.class.php";
require_once "views/ErrorOrSuccessView.class.php";
$viewG = new GeneralView();
$errorView = new ErrorOrSuccessView();
$viewG->header("Inscription");
//if we dont have already complete the form, show it
if (!isset($_POST['inscription'])) {
    $viewG->inscriptionPage();
    //since here we will check all fields in the form
} elseif (!isset($_POST['login']) && $_POST['login'] == '') {
    $errorView->errorCompleteForm("login");
    $errorView->redirection(5);
    header('Refresh: 5; url=inscription.php');
} elseif (!isset($_POST['pwd']) && $_POST['pwd'] == '') {
    $errorView->errorCompleteForm("mot de passe");
    $errorView->redirection(5);
    header('Refresh: 5; url=inscription.php');
} elseif (!isset($_POST['nom']) && $_POST['nom'] == '') {
    $errorView->errorCompleteForm("nom");
} elseif (!isset($_POST['prenom']) && $_POST['prenom'] == '') {
    $errorView->errorCompleteForm("prenom");
    $errorView->redirection(5);
    header('Refresh: 5; url=inscription.php');
} elseif (!isset($_POST['adresse']) && $_POST['adresse'] == '') {
    $errorView->errorCompleteForm("adresse");
    $errorView->redirection(5);
    header('Refresh: 5; url=inscription.php');
    //last check if the two password are the same
} elseif ($_POST['pwd'] != $_POST['pwdConfirm']) {