-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
63 lines (49 loc) · 1.47 KB
/
signup.php
File metadata and controls
63 lines (49 loc) · 1.47 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
<?php
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/handler.php';
/**
* Signup page controller
*/
class Signup extends BaseHandler {
private $_required = ['first_name', 'last_name', 'email', 'social', 'hear', 'about'];
public function prepare(){
$this->ensureSettingOr500('slack_signup_webhook');
}
public function get(){
$content = $this->load('sign-up.html');
return $this->page($content);
}
public function post(){
if(!$this->isAjax()){
$this->redirect('/sign-up');
}
$errors = [];
$slack = [];
$message = 'Thank you for signing up! We will get back to you shortly.';
foreach($this->_required as $field){
$pass = false;
if(isset($_POST[$field])){
$val = strip_tags(trim($_POST[$field]));
$pass = $val != '';
if($field == 'about' && $pass){
$pass = strlen($val) < 500;
}
}
if(!$pass){
$errors[] = $field;
}else{
$slack[$field] = $val;
}
}
if(!count($errors)){
$this->postToSlack($slack);
}else{
$message = 'Please correct the form errors to continue your submission.';
}
$resp = [
'errors' => $errors,
'message' => $message,
];
return $this->json($resp);
}
}