} else { $post_data[$value] = ""; } } $conditions[$category] = substr($conditions[$category], 0, -4); if ($data) { $conditions[$category] = $conditions[$category] . ")"; } else { $conditions[$category] = ""; } } $filter = ""; foreach ($conditions as $key => $value) { if (!empty($value)) { $filter = $filter . $value . " AND "; } } $filter = substr($filter, 0, -5); } else { // If no post operation is set, don't load anything from DB. $filter = "nothing"; } $farmer = new FarmerForm(); $landO = new LandownerForm(); $farmer->load_by_filter($filter); $landO->load_by_filter($filter); $logout = "logout_button.php"; $page_title = "Admin page"; $panel_heading = "Welcome back, " . $_SESSION['first_name'] . '!'; $page_body = "admin_template.php"; include "templates/template.php";
//check if the typed password matches the one in the database, if so the user will be logged in and directed to the correct page, else redirect to login page $valid_password = false; $redirect = ""; if ($login_fields['user_type'] == "Farmer") { $form = new FarmerForm(); $checkQuery = $form->load_by_filter(array("email" => $_POST['email'])); if ($checkQuery) { if ($form->fields['password']->authenticate($_POST['password'])) { $redirect = "Location: farmer_view.php"; $valid_password = true; } } } if ($login_fields['user_type'] == "Landowner") { $form = new LandownerForm(); $checkQuery = $form->load_by_filter(array("email" => $_POST['email'])); if ($checkQuery) { if ($form->fields['password']->authenticate($_POST['password'])) { $redirect = "Location: landowner_view.php"; $valid_password = true; } } } if ($login_fields['user_type'] == "Administrator") { $form = new AdminForm(); $checkQuery = $form->load_by_filter(array("email" => $_POST['email'])); if ($checkQuery) { if ($form->fields['password']->authenticate($_POST['password'])) { $redirect = "Location: admin.php"; $valid_password = true; }