function update($establishment)
{
    $e = new Establishment();
    $boolean = $e->isValid($establishment);
    if ($boolean == false) {
        $msg = serialize("Validation fail. Fill all form inputs.");
        header("Location: ../views/editProfileEstablishment.php?val={$msg}");
    } else {
        $id = $_SESSION["name"];
        $bool = $e->update($establishment, $id);
        if ($bool == true) {
            $_SESSION["name"] = $establishment["name"];
            $msg = serialize("Your profile have been updated.");
            header("Location: ../views/editProfileEstablishment.php?upd={$msg}");
        } else {
            $msg = serialize("Server Error: Profile not changed");
            header("Location: ../views/editProfileEstablishment.php?err={$msg}");
        }
    }
}
示例#2
0
        if ($action == 'update') {
            $error = 0;
            if (!$cancel) {
                $name = GETPOST('name', 'alpha');
                if (empty($name)) {
                    setEventMessages($langs->trans('ErrorFieldRequired', $langs->trans('Name')), null, 'errors');
                    $error++;
                }
                if (empty($error)) {
                    $object->name = GETPOST('name', 'alpha');
                    $object->address = GETPOST('address', 'alpha');
                    $object->zip = GETPOST('zipcode', 'alpha');
                    $object->town = GETPOST('town', 'alpha');
                    $object->country_id = $_POST["country_id"];
                    $object->fk_user_mod = $user->id;
                    $result = $object->update();
                    if ($result > 0) {
                        header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']);
                        exit;
                    } else {
                        setEventMessages($object->error, $object->errors, 'errors');
                    }
                }
            } else {
                header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']);
                exit;
            }
        }
    }
}
/*