public function update($f3, $param) { $table = MyConst::$tables[$param['table']]; $cols = MyConst::$cols[$param['table']]; $article = new Article($this->db, $table, $cols); if ($this->f3->exists('POST.updateArticle')) { if (isset($_POST['description'])) { $_POST['description'] = str_replace(array('.', ' ', "\n", "\t", "\r"), '', $_POST['description']); } $this->updateAttachment($table); $article->edit($this->f3->get('POST.id')); $this->f3->reroute("/list/" . $param['table']); } else { $article->getById($this->f3->get('PARAMS.id')); $this->f3->set('article', $article); $this->f3->set('VIEWTABLE', $param['table']); $this->f3->set('view', "/" . $param['table'] . "/update.html"); echo Template::instance()->render('layout.htm'); } }
<?php $edit = new Article($DB); //POST Daten in Variable speichern $id = htmlspecialchars($_POST['id']); $value = htmlspecialchars($_POST['value']); $q_result = $edit->edit($id, $value); //1 Sekunde warten für Speichertext usleep(500000); echo $value;
$article = Model::factory('Article')->find_one($id); if (!$article instanceof Article) { $app->notFound(); } if ($article->author === $_COOKIE['login']) { $user_name = $_COOKIE['login']; return $app->render('posts_input.html', array('action_name' => 'Edit', 'action_url' => '/newtest/posts/edit/' . $id, 'article' => $article, 'isLoginned' => $isLoginned, 'User_name' => $user_name)); } } $app->redirect('/newtest'); }); // Posts Edit - POST. $app->post('/posts/edit/(:id)', function ($id) use($app) { $isLoginned = User::isLoginned(); if ($isLoginned) { $article = Model::factory('Article')->find_one($id); if (!$article instanceof Article) { $app->notFound(); } if ($article->author === $_COOKIE['login']) { $title = $app->request()->post('title'); $summary = $app->request()->post('summary'); $content = $app->request()->post('content'); $timestamp = date('Y-m-d H:i:s'); Article::edit($id, $title, $summary, $content, $timestamp); } } $app->redirect('/newtest'); }); // Slim Run. $app->run();