Skip to content

Commit 4c47ecb

Browse files
added new features, fixed bugs
added new features, fixed bugs
1 parent 9294a60 commit 4c47ecb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+8985
-41
lines changed

createacc.php

+36-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
include "server_vars.php";
44

5-
$errors = 0;
6-
$error_string = "";
5+
if($_COOKIE["logged"] == 1)
6+
{
7+
header("Location: player.php");
8+
}
9+
10+
session_start();
11+
12+
$no_err = 0;
13+
$errors = "";
714

815
$regname = strip_tags($_POST["regname"]);
916
$regpass = strip_tags($_POST["regpass"]);
@@ -14,9 +21,10 @@
1421

1522
if($regpass != $confpass)
1623
{
17-
$errors++;
18-
$error_string .= "Passwords don't match!<br>";
19-
//header("Location: signup.php");
24+
$no_err++;
25+
$errors .= "Passwords don't match!<br>";
26+
$_SESSION["signup_errors"] = $errors;
27+
header("Location: signup.php");
2028
}
2129
else
2230
{
@@ -27,19 +35,21 @@
2735

2836
if($conn->connect_errno)
2937
{
30-
echo "MySQLi error occurred: " . $conn->connect_error;
38+
$no_err++;
39+
$errors .= "Database error<br>";
3140
}
3241
else
3342
{
3443
echo "MySQLi connection successfully established!";
3544
}
3645

37-
if($q1 = $conn->prepare("SELECT COUNT(*) FROM coreaccounts WHERE username=?"))
46+
if($q1 = $conn->prepare("SELECT username FROM coreaccounts WHERE username=?"))
3847
{
3948
$q1->bind_param("s", $regname);
4049
$q1->execute();
41-
$q1->bind_result($count);
50+
$q1->bind_result($ret_username);
4251
$q1->store_result();
52+
$count = $q1->num_rows;
4353
if($count == 0)
4454
{
4555
if($q2 = $conn->prepare("INSERT INTO coreaccounts VALUES (?, ?, ?, ?, ?)"))
@@ -49,21 +59,36 @@
4959
if($q2->affected_rows > 0)
5060
{
5161
echo "Successfully created an account!<br>";
62+
unset($_SESSION["signup_errors"]);
5263
}
5364
else
5465
{
55-
echo "Query Failed!: " . $conn->error;
66+
$no_err++;
67+
$errors .= "Error creating account, try again<br>";
5668
}
5769
}
5870
else
5971
{
60-
echo "Query Failed!: " . $conn->error;
72+
$no_err++;
73+
$errors .= "Database Error";
6174
}
6275
}
76+
else
77+
{
78+
$no_err++;
79+
$errors .= "Account already exists<br>";
80+
}
6381
}
6482
else
6583
{
66-
echo "Query Failed!: " . $conn->error;
84+
$no_err++;
85+
$errors .= "Database Error";
86+
}
87+
88+
if($no_err > 0)
89+
{
90+
$_SESSION["signup_errors"] = $errors;
91+
header("Location: signup.php");
6792
}
6893

6994
?>

faces/angry.jpg

19.9 KB
Loading

0 commit comments

Comments
 (0)