-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup.php
36 lines (30 loc) · 951 Bytes
/
signup.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
<?php
require_once("inc/controller.php");
if($session->is_logged_in()){
redirect_to("timeline.php");
}
if(isset($_POST["submit"])){
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$password_repeat = $_POST["password_repeat"];
$profile_picture = "/uploads/default.png";
$user = new User();
if($user->input_validates($username, $email, $password, $password_repeat)){
$user->username = $username;
$user->email = $email;
$user->password = $password;
$user->profile_picture = $profile_picture;
$user->create();
$_SESSION["message"] = "Welcome on board! positive";
redirect_to("index.php");
} else {
// $_SESSION["message"] gets set by the input_validates method
// so no need to set here
redirect_to("index.php");
}
} else { // form has not been submitted
$_SESSION["message"] = "Something went wrong! negative";
redirect_to("index.php");
}
?>