function processForm($postImage) { $errors = []; $errors['count'] = 0; $today = date("Y-m-d"); //pass this to be inserted into the database //form was submitted when $_POST is not empty if (!empty($_POST)) { try { $category = Input::getString('category'); } catch (Exception $e) { $errors['category'] = 'Category: ' . $e->getMessage(); $errors['count']++; } try { $postingTitle = Input::getString('title'); } catch (Exception $e) { $errors['title'] = 'Posting Title: ' . $e->getMessage(); $errors['count']++; } try { $price = Input::getNumber('price'); } catch (Exception $e) { $errors['price'] = 'Price: ' . $e->getMessage(); $errors['count']++; } try { $description = Input::getString('description'); } catch (Exception $e) { $errors['description'] = 'Description: ' . $e->getMessage(); $errors['count']++; } try { $date_posted = Input::getDate('date_posted'); } catch (Exception $e) { $errors['date_posted'] = 'Date Posted: ' . $e->getMessage(); $errors['count']++; } if ($errors['count'] == 0) { $adObject = new AdModel(); $adObject->category = $category; $adObject->title = $postingTitle; $adObject->price = $price; $adObject->description = $description; var_dump($postImage); $adObject->image = $postImage; $adObject->date_posted = $today; // hardcoded: $adObject->user_id = $_SESSION['user_id']; $adObject->users_id = 1; $adObject->save(); //unset the $_SESSION['image'] - will be using the one in the database unset($_SESSION['image']); header("Location: /ads.show.php?id=" . $adObject->id); //this will be the $_GET for the ads.show.php die; } } return $errors; }