if (isset($_GET['path'])) { $_SESSION['path_selection'] = 'choose old device'; } if (isset($_GET['action'])) { $product_dao = new ProductDAO(); if ($_GET['action'] == 'Search') { $product = $product_dao->findBySerialNumber($_GET['serial_number']); } if ($_GET['action'] == 'Select your new device' || $_GET['action'] == 'Compare') { if ($_GET['modelchoice'] == 'yes') { $product = $product_dao->findOldProduct($_GET['category'], $_GET['specification'], $_GET['brand'], $_GET['model']); } else { //put the average consumption of all the products according to the category in a session $_SESSION['old_energy_consumption'] = $product_dao->avgconsumptionByCategory($_GET['category']); //put the average price of all the products according to the category in a session $_SESSION['old_puchase_price'] = $product_dao->avgPriceByCategory($_GET['category']); $_SESSION['purchase_year'] = $_GET['purchase_year']; $_SESSION['old_product_id'] = 0; //if the user chose to select his old device first, we redirect him in the page new_device.php so he can select his new device if ($_SESSION['path_selection'] == 'choose old device') { header('Location: new_device.php?category=' . $_GET['category'] . '&specification=' . $_GET['specification']); } else { //if the user chose to select his old device first, we redirect him in the page profits.php header('Location: profits.php'); } } } // if we haven't found a product according to the informations entered by the user, we display an error message if ($product == false) { $error_message = '<span class="text-danger">*' . 'No result found' . '</span>'; } else {