-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
59 lines (47 loc) · 1.9 KB
/
index.php
File metadata and controls
59 lines (47 loc) · 1.9 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
<?php
//We should write some sort of validation to make sure that people aren't trying to sign up with emails that are already in the system.
session_set_cookie_params(0);
session_start();
/* include "models/admin_model.php";
$pass = new PasswordField();
$pass->new_password(MartinRichards);
echo $pass->value; */
//the following arrays are used to populate the form, and indicate error message in each field, if the post operation received false/incomplete/invalid data
$fields = array('fname' => '', 'lname' => '', 'email'=> '', 'password'=> '', 'password_confirm'=> '', 'choosePurpose' => '', 'phone' => '', 'street' => '', 'city' => '', 'zip' => '');
$error = array('fname' => '', 'lname' => '', 'email'=> '', 'password'=> '', 'password_confirm'=> '', 'choosePurpose' => '', 'phone' => '', 'street' => '', 'city' => '', 'zip' => '');
$valid = true;
if (!empty($_POST)){//if post exists, then store the data in the arrays if the field is not empty
foreach ($fields as $key => $value){
if (!empty($_POST[$key])){
$fields[$key] = $_POST[$key];
} else {
$valid = false;
$error[$key] = "This field is required";
}
}
if ($valid and $fields["password_confirm"] != $fields["password"]){
$fields["password_confirm"] = "";
$fields["password"] == "";
$error["password"] = "Passwords must match";
$valid = false;
}
if ($valid){
foreach ($fields as $key => $value) {// set session variable
$_SESSION[$key] = $value;
}
if ($fields['choosePurpose'] == "farmer"){// depending on the type of the user, take the user to the corresponding page/questionnaire
header('Location: farmerq.php');
die();
} elseif($fields['choosePurpose'] == "landowner") {
header('Location: landownerq.php');
die();
}
}
}
$login = "login_button.php";
// Add support for Select
$page_title = "Register";
$panel_heading = "Register";
$page_body = "register_template.php";
include "templates/template.php";
?>