-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign-up.php
86 lines (52 loc) · 1.66 KB
/
sign-up.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* I Have Plans -- Sign Up controller
* @author Steven Dufresne <[email protected]>
* @link http://github.com/StevenDufresne/web-app
* @copyright 2012 Steven Dufresne
* @license BSD-3-Clause <https://github.com/stevendufresne/web-app/BSD-3-CLAUSE-LICENSE.txt>
*/
require_once 'includes/db.inc.php';
require_once 'includes/users.inc.php';
require_once 'includes/requests.inc.php';
require_once 'includes/functions.inc.php';
$errors = array();
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_UNSAFE_RAW);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$file_tmp = $_FILES['photo']['tmp_name'];
//check to make sure the name doesn't already exist
$name_check = friend_check( $db, $username );
if( $name_check ) {
$errors['user-exists'] = true;
}
if ( empty($username) ) {
$errors['username'] = true;
}
if ( empty($password) ) {
$errors['password'] = true;
}
if ( strlen($email) < 2 || strlen($email) > 50 ) {
$errors['email'] = true;
}
if ( empty($errors) ) {
if ( $_FILES['photo']['name'] == "" ) {
//if no pic set it to default pic
$photo_name = "nopic.jpg";
} else {
$photo_name = stripslashes( $_FILES['photo']['name'] );
}
// create the user
$id = user_create($db, $username, $password, $email, $photo_name);
var_dump($id);
//resize and move the screenshot to the images folder
if($_FILES['photo']['name'] !== "" ) {
image_resize_move($file_tmp, $photo_name);
}
header('Location: index.php');
exit;
}
}
include "views/sign-up.html.php";
?>