示例#1
0
     $form = new FarmerForm();
     $form->load_by_pk($_SESSION['usr_id']);
 } elseif ($_SESSION['type'] == "Administrator") {
     if (isset($_POST['farmer_id'])) {
         $form = new FarmerForm();
         $form->load_by_pk($_POST['farmer_id']);
     } else {
         header('Location: admin.php');
     }
 } else {
     header('Location: index.php');
 }
 //handle post operation
 $saved = false;
 if (isset($_POST['submit'])) {
     $form->load_from_post();
     // Sets the "describe" fields to not required if the checkbox isn't set
     if (!$form->fields['to_other']->value) {
         $form->fields['terms_other']->set_required(false);
     }
     if (!$form->fields['housing']->value) {
         $form->fields['describe_housing']->set_required(false);
     }
     if (!$form->fields['equipment']->value) {
         $form->fields['equipment_other']->set_required(false);
     }
     $is_valid = $form->validate();
     if ($is_valid and isset($_POST['submit'])) {
         if ($form->save()) {
             $saved = true;
             /* session_unset(); 
示例#2
0
<?php

session_set_cookie_params(0);
session_start();
if (!empty($_SESSION['email'])) {
    include "models/farmer_model.php";
    $form = new FarmerForm();
    $data = $form->load_from_post();
    //load data from the post operation to the fields array
    $data = $form->load_from_post();
    $form->fields['enabled']->set_value(true);
    if (!$form->fields['to_other']->value) {
        $form->fields['terms_other']->set_required(false);
    }
    if (!$form->fields['housing']->value) {
        $form->fields['describe_housing']->set_required(false);
    }
    if (!$form->fields['equipment']->value) {
        $form->fields['equipment_other']->set_required(false);
    }
    //store the data from the registration page into the fields array of the current farmer object
    $form->fields['first_name']->set_value($_SESSION['fname']);
    $form->fields['last_name']->set_value($_SESSION['lname']);
    $form->fields['email']->set_value($_SESSION['email']);
    $form->fields['first_name']->set_value($_SESSION['fname']);
    $form->fields['phone']->set_value($_SESSION['phone']);
    $form->fields['street']->set_value($_SESSION['street']);
    $form->fields['city']->set_value($_SESSION['city']);
    $form->fields['zip']->set_value($_SESSION['zip']);
    $form->fields['password']->new_password($_SESSION['password']);
    // If data is received, validate it.