-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateacc.php
95 lines (84 loc) · 1.68 KB
/
createacc.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
87
88
89
90
91
92
93
94
95
<?php
include "server_vars.php";
if($_COOKIE["logged"] == 1)
{
header("Location: player.php");
}
session_start();
$no_err = 0;
$errors = "";
$regname = strip_tags($_POST["regname"]);
$regpass = strip_tags($_POST["regpass"]);
$confpass = strip_tags($_POST["confpass"]);
$regmail = strip_tags($_POST["regmail"]);
$phone = strip_tags($_POST["phone"]);
$today = time();
if($regpass != $confpass)
{
$no_err++;
$errors .= "Passwords don't match!<br>";
$_SESSION["signup_errors"] = $errors;
header("Location: signup.php");
}
else
{
$regpass = md5($regpass);
}
$conn = new mysqli($HOST, $USERNAME, $PASSWORD, $DBNAME_CORE);
if($conn->connect_errno)
{
$no_err++;
$errors .= "Database error<br>";
}
else
{
echo "MySQLi connection successfully established!";
}
if($q1 = $conn->prepare("SELECT username FROM coreaccounts WHERE username=?"))
{
$q1->bind_param("s", $regname);
$q1->execute();
$q1->bind_result($ret_username);
$q1->store_result();
$count = $q1->num_rows;
if($count == 0)
{
if($q2 = $conn->prepare("INSERT INTO coreaccounts VALUES (?, ?, ?, ?, ?)"))
{
$q2->bind_param("sssii", $regname, $regpass, $regmail, $phone, $today);
$q2->execute();
if($q2->affected_rows > 0)
{
echo "Successfully created an account!<br>";
unset($_SESSION["signup_errors"]);
header("Location: regsuccess.php");
}
else
{
$no_err++;
$errors .= "Error creating account, try again<br>";
}
}
else
{
$no_err++;
$errors .= "Database Error";
}
}
else
{
$no_err++;
$errors .= "Account already exists<br>";
}
}
else
{
$no_err++;
$errors .= "Database Error";
}
if($no_err > 0)
{
$_SESSION["signup_errors"] = $errors;
header("Location: signup.php");
}
?>