// <div class='form-group'> // <label for='phone'>Enter the phone numba:</label> // <input id='phone' name='phone' class='form-control' type='number'> // </div> // <button type='submit' class='btn-success'>Create</button> // </form> // </div> // </body> // </html> // "; // }); $app->post("/view_job", function () { $output = ""; $new_contact = new Contact($_POST["name"], $_POST["email"], $_POST["phone"]); $new_job = new JobOpening($_POST["title"], $_POST["description"], $new_contact); $new_job->save(); $title = $new_job->getTitle(); $description = $new_job->getDescript(); $job_contact = $new_job->getContact(); $name = $job_contact->getName(); $email = $job_contact->getEmail(); $number = $job_contact->getPhoneNumba(); // $available_jobs = array(); // // array_push($available_jobs, $new_job); // // var_dump($available_jobs); return "\n <h1>Here is your new job listing:</h1>\n <h3>{$title}</h3>\n <h4>{$description}</h4>\n <ul>\n <li>{$name}</li>\n <li>{$email}</li>\n <li>{$number}</li>\n </ul>\n \n "; }); $app->post("/delete_jobs", function () { JobOpening::deleteAll();
<?php require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/JobOpening.php"; require_once __DIR__ . "/../src/Contact.php"; session_start(); if (empty($_SESSION['list_of_jobs'])) { $_SESSION['list_of_jobs'] = array(); } $app = new Silex\Application(); $app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views')); $app->get("/", function () use($app) { return $app['twig']->render('form.html.twig'); }); $app->get("/result", function () use($app) { // $title = $_GET['title']; // $description = $_GET['description']; // $name = $_GET['name']; // $phone = $_GET['phone']; // $email = $_GET['email']; // refactored $contact = new Contact($_GET['name'], $_GET['phone'], $_GET['email']); $job = new JobOpening($_GET['title'], $_GET['description'], $contact); $job->save(); return $app['twig']->render('result.html.twig', array('jobs' => $_SESSION['list_of_jobs'])); }); return $app;