-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfarmerq.php
More file actions
70 lines (55 loc) · 2.09 KB
/
Copy pathfarmerq.php
File metadata and controls
70 lines (55 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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.
$is_valid = true;
if($data){
$is_valid = $form->validate();//validate the data. if valid save it to the database. if not redirect the user to the farmerq page
if ($is_valid){
if($form->save()){
session_destroy();
header('Location: confirmation.php');
die();
} else {
session_destroy();
die("Something has gone horribly wrong with our database. Please try submitting your application again later.");
header('Refresh: 5; url = farmerq.php');
}
}
}
$page_title = "Farmer Questionnaire";
$panel_heading = "Hello ". $form->fields['first_name'] . " " . $form->fields['last_name'] ."! Tell us about yourself.";
$page_body = "farmer_template.php";
include "templates/template.php";
}
else {
session_unset();
session_destroy();
header('Location: index.php');
}
?>