예제 #1
0
파일: admin.php 프로젝트: SirTekno/cfa_dev
            } 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";
예제 #2
0
파일: login.php 프로젝트: SirTekno/cfa_dev
 foreach ($login_fields as $key => $value) {
     if (!empty($_POST[$key])) {
         $login_fields[$key] = $_POST[$key];
     } else {
         $valid = false;
         $errors[$key] = "This field is required";
     }
 }
 if ($valid) {
     //if the fields are valid, do the login query
     //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;
             }