Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!empty($_POST)){
- $con = new AppControllerCreateController();
- if ($con->create(['name' => $_POST['title'], 'content' => $_POST['content'], 'users_id' => $_SESSION['log']]) && $con->media(['name' => $_FILES['image']['tmp_name'], 'post_id' => ID DU POST ]) ){
- ?>
- <div class="alert-success">Post Created !</div>
- <?php
- header('refresh:2;url= ../public/admin.php?p=home');
- }
- }
- public function create($attributes){
- $dats = [];
- $vars = [];
- $preps = [];
- foreach ($attributes as $k => $v){
- $dats[] = $k;
- $vars[] = "?";
- $preps[] = $v;
- }
- $dat = implode(', ' , $dats);
- $var = implode(', ' , $vars);
- $app = new App();
- return $app->getDB()->prepare("INSERT INTO posts ($dat) VALUES ($var)" , $preps , 'AppTablePostsTable');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement