require "connectToDataBase.inc.php";
if (isset($_REQUEST['save'])) {
    // handle ajax save request (do not show the interface)
    $ID = @$_REQUEST['ID'];
    // we posted . characters, but something converts them to _ (HTTP 1.1 standard)
    $r = array();
    foreach ($_REQUEST as $i => $v) {
        $r[join('.', explode('_', $i))] = $v;
        //convert _ back to .
    }
    $sessies = array();
    for ($i0 = 0; isset($r['0.' . $i0]); $i0++) {
        $sessies[$i0] = @$r['0.' . $i0 . ''];
    }
    $Gebruiker = new Gebruiker($ID, $sessies);
    if ($Gebruiker->save() !== false) {
        die('ok:' . serviceref($_REQUEST['content']) . '&Gebruiker=' . urlencode($Gebruiker->getId()));
    } else {
        die('Please fix errors!');
    }
    exit;
    // do not show the interface
}
$buttons = "";
if (isset($_REQUEST['new'])) {
    $new = true;
} else {
    $new = false;
}
if (isset($_REQUEST['edit']) || $new) {
    $edit = true;
Пример #2
0
 public function createAccountAction()
 {
     // checks if a post is committed
     if ($this->request->isPost()) {
         // check for CSRF security
         if ($this->security->checkToken() == false) {
             $this->flash->error("invalid CSRF token ");
             $this->response->redirect('account/index');
         }
         // saves input from form in a variable
         $email = $this->request->getPost('email');
         $username = $this->request->getPost('username');
         $voornaam = $this->request->getPost('voornaam');
         $tussenvoegsel = $this->request->getPost('tussenvoegsel');
         $achternaam = $this->request->getPost('achternaam');
         $telefoonnummer = $this->request->getPost('telefoonnummer');
         $password = $this->request->getPost('password');
         $confirm_password = $this->request->getPost('confirm_password');
         // checks if both password fields are equal
         if ($password != $confirm_password) {
             $this->flash->warning('de ingevulde wachtwoorden zijn niet gelijk');
             $this->response->redirect('account/register');
         }
         // initiate model
         $gebruiker = new Gebruiker();
         // assign post input to a field form the table
         $gebruiker->rol = "user";
         $gebruiker->email = $email;
         $gebruiker->username = $username;
         $gebruiker->tussenvoegsel = $tussenvoegsel;
         $gebruiker->voornaam = $voornaam;
         $gebruiker->achternaam = $achternaam;
         $gebruiker->telefoonnummer = $telefoonnummer;
         $gebruiker->password = $password;
         // save the inputs in the table
         $result = $gebruiker->save();
         // checks if any invalid values are past
         if (!$result) {
             $output = [];
             foreach ($gebruiker->getMessages() as $message) {
                 $output[] = $message;
             }
             $output = implode("<br><br>", $output);
             // displays incorrect input
             $this->flash->error($output);
             $this->response->redirect('account/register');
             return;
         }
         $this->registerSession($gebruiker);
         $this->response->redirect('afspraak/index');
     }
 }