-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlandownerq.php
More file actions
66 lines (55 loc) · 1.98 KB
/
landownerq.php
File metadata and controls
66 lines (55 loc) · 1.98 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
<?php
session_set_cookie_params(0);
session_start();
if(!empty($_SESSION['email'])){
include "models/landowner_model.php";
$form = new LandownerForm();
$data = $form->load_from_post();
$form = new LandownerForm();
$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 registraiton page to the fields array of the landowner object for later validation and insertion into the database
$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();
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.");
}
}
}
$page_title = "Landowner Questionnaire";
$panel_heading = "Hello ". $form->fields['first_name'] . " " . $form->fields['last_name'] ."! Tell us about your farm.";
$page_body = "landowner_template.php";
include "templates/template.php";
}
else {
session_unset();
session_destroy();
header('Location:index.php');
}
?>