Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. if(!empty($_POST)){
  2.  
  3. $con = new AppControllerCreateController();
  4.  
  5. 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 ]) ){
  6. ?>
  7. <div class="alert-success">Post Created !</div>
  8. <?php
  9. header('refresh:2;url= ../public/admin.php?p=home');
  10. }
  11. }
  12.  
  13. public function create($attributes){
  14.  
  15. $dats = [];
  16. $vars = [];
  17. $preps = [];
  18. foreach ($attributes as $k => $v){
  19.  
  20. $dats[] = $k;
  21. $vars[] = "?";
  22. $preps[] = $v;
  23. }
  24. $dat = implode(', ' , $dats);
  25. $var = implode(', ' , $vars);
  26.  
  27. $app = new App();
  28. return $app->getDB()->prepare("INSERT INTO posts ($dat) VALUES ($var)" , $preps , 'AppTablePostsTable');
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement