foreach ($files as $value) { $file_id = $value['id']; //$userFile_id = $value['user_id']; } $commentObj = new Comment(); $commentObj->file_id = $file_id; $commentMapper = new CommentMapper($db); $comments = $commentMapper->select($commentObj); ini_set('display_errors', 'Off'); $checkrights = new Checkrights(); $checkrights->Render($files, $app, $comments); if (!empty($_POST['comment'])) { $logged = new Logged(); $cookie = $app->getCookie('username'); $user_id = $logged->getLogged($db, $cookie); $postcomment = new postComment($file_id, $user_id, $db); $regExp = new RegExp(); $comment = $regExp->match(trim($_POST['comment'])); $postcomment->post($comment); $app->redirect("{$id}"); } if (isset($_POST['public'])) { $regExp = new RegExp(); $tags = $regExp->match(trim($_POST['tags'])); $description = $regExp->match(trim($_POST['description'])); $public = $regExp->match($_POST['public']); $terminate = $regExp->match($_POST['terminate']); $foo = new Foo(); $foo->id = $file_id; $foo->tags = $tags; $foo->public = $public;
<?php $app->post('/file/:id', function ($id) use($app) { if (isset($_POST)) { $db = $app->db; $logged = new Logged(); $cookie = $app->getCookie('username'); $user_id = $logged->getLogged($db, $cookie); $comment = new postComment($id, $user_id, $db); $comment->post($_POST); $comment->save(); $app->redirect("file/{$id}"); } })->name('comment');