-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
47 lines (31 loc) · 1.15 KB
/
Copy pathcreate.php
File metadata and controls
47 lines (31 loc) · 1.15 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
<?php
/*
Script:
User creation script
Function:
The purpose of this script is to create a new user.
If creation occurred successfully, the user should automatically be logged in and the script sets:
'secured' cookie - true - indicates that the user is logged in
'connected' cookie - username - stores the username of the user that is newly logged in
These cookies are also set to expire immediately.
Redirect to the home page at the end of the script.
*/
//includes
include "class/Handler.php";
include "class/User.php";
//DB connection using Handler class
$handler = new Handler("root", "", "UploadImages");
$handler->connect();
$errorCode = User::create($handler, $_POST['name'], $_POST['password'], $_POST['email']);
$handler = null;
$headerLocation = "Location: index.php";
if ($errorCode === 0) {
$expiry = time() + 60*60*24; //60*60*24 = 1 day, multiply further to get 1 month or more
$secured = "true";
$connected = $_POST['name'];
setcookie("secured", $secured, $expiry, "", "", "", TRUE);
setcookie("connected", $connected, $expiry, "", "", "", TRUE);
}
header($headerLocation);
exit();
?>