public function newAction() { if (!isset($this->admin_session->user)) { header("Location: /"); } $project_model = new ProjectModel(); $contributions_model = new ContributionModel(); $image_model = new ImageModel(); $contributions = explode(", ", $_POST['contributions']); $project = array($_POST['title'], $_POST['description'], $_POST['url']); //Create project $project_id = $project_model->addOne($project); //Create default image $image_model->addDefault($project_id); if ($project_id && !empty($contributions)) { foreach ($contributions as $contribution) { $contributions_model->addOne(array($project_id), array($contribution)); } } header("Location: /admin/projects"); }