diff --git a/addaccounts.php b/addaccounts.php
index 25975cb..29ed9aa 100644
--- a/addaccounts.php
+++ b/addaccounts.php
@@ -1,98 +1,91 @@
prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)");
- $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']);
- $addacc->execute();
- $addacc->close();
- echo 'New account added, returning to editor.';
- header ("Refresh:1; url=addaccounts.php");
- exit();
-}
+ if (!empty($_POST['accemail'])) {
+ // this section contains the code to add a new game account to track
+ include_once ('includes/addaccount-submit.php');
+ }
-if (!empty($_POST['delchar'])) {
- echo 'removing selected character(s) from selected account ';
- if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
- $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
- for ($i = 0; $i < count($_POST['delchar']); $i++) {
- $delcharid = $_POST['charid'][$i];
- $delaccid = $_POST['accid'][$i];
- $delchar->execute();
- }
- $delchar->close();
+ if (!empty($_POST['delcharid'])) {
+ // this section contains code to delete the selected characters
+ include_once ('includes/del-character.php');
}
- $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
- $nap->bind_param("i", $_SESSION['userid']);
- $nap->execute();
- $nap->close();
- $_SESSION['prefcharid'] = "0";
- $_SESSION['prefcharname'] = "No default selected";
- echo 'Character deleted - no preferred character selected.
';
-}
-if (!empty($_POST['newcharname'])) {
- include_once ('includes/addcharacters-submit.php');
-}
+ if (!empty($_POST['newcharname'])) {
+ // this section contains code to insert a new character into the database
+ include_once ('includes/addcharacters-submit.php');
+ }
-echo '
';
-// add characters here
-echo ' ';
+ // add characters here
+ echo ' ';
-echo ' ';
-echo ' Return to your user page';
+ echo ' ';
+ echo ' Return to your user page';
}
include_once ('footer.php');
?>
\ No newline at end of file
diff --git a/includes/addaccount-submit.php b/includes/addaccount-submit.php
new file mode 100644
index 0000000..b8efe28
--- /dev/null
+++ b/includes/addaccount-submit.php
@@ -0,0 +1,11 @@
+prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)");
+ $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']);
+ $addacc->execute();
+ $addacc->close();
+ echo 'New account added, returning to editor.';
+ header ("Refresh:1; url=addaccounts.php");
+ exit();
+}
+?>
\ No newline at end of file
diff --git a/includes/addcharacters-submit.php b/includes/addcharacters-submit.php
index 820cc0a..100b390 100644
--- a/includes/addcharacters-submit.php
+++ b/includes/addcharacters-submit.php
@@ -1,15 +1,13 @@
prepare("SELECT profcolor FROM gwprofessions WHERE profid = ?");
+ $pc->bind_param("i", $_POST['profid']);
+ $pc->execute();
+ $profcolor = $pc->get_result()->fetch_object()->profcolor;
// $ac = AddCharacter
- $ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid) VALUES (?, ?, ?, ?, ?)");
- $ac->bind_param("iissi", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid']);
+ $ac = $con->prepare("INSERT INTO gwchars (accid, userid, charname, birthdate, profid, profcolor) VALUES (?, ?, ?, ?, ?, ?)");
+ $ac->bind_param("iissis", $_SESSION['prefaccid'], $_SESSION['userid'], $_POST['newcharname'], $_POST['bdate'], $_POST['profid'], $profcolor);
$ac->execute();
$ac->close();
echo $_POST['newcharname'] . ' added to your account!
';
diff --git a/includes/del-character.php b/includes/del-character.php
new file mode 100644
index 0000000..feb8222
--- /dev/null
+++ b/includes/del-character.php
@@ -0,0 +1,21 @@
+';
+ if ($delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?")) {
+ $delchar->bind_param("iii", $delcharid, $delaccid, $_SESSION['userid']);
+ for ($i = 0; $i < count($_POST['delcharid']); $i++) {
+ $delcharid = $_POST['delcharid'][$i];
+ $delaccid = $_POST['accid'][$i];
+ $delchar->execute();
+ }
+ $delchar->close();
+ }
+ $nap = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?");
+ $nap->bind_param("i", $_SESSION['userid']);
+ $nap->execute();
+ $nap->close();
+ $_SESSION['prefcharid'] = "0";
+ $_SESSION['prefcharname'] = "No default selected";
+ echo 'Character(s) deleted - no preferred character selected.
';
+}
+?>
\ No newline at end of file
diff --git a/includes/getaccountstats.php b/includes/getaccountstats.php
new file mode 100644
index 0000000..4500c9f
--- /dev/null
+++ b/includes/getaccountstats.php
@@ -0,0 +1,23 @@
+
';
+}
+$gas->close();
+echo '';
+?>
\ No newline at end of file
diff --git a/includes/session-debug.php b/includes/session-debug.php
new file mode 100644
index 0000000..9700053
--- /dev/null
+++ b/includes/session-debug.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/includes/session-dump.php b/includes/session-dump.php
new file mode 100644
index 0000000..20f65ec
--- /dev/null
+++ b/includes/session-dump.php
@@ -0,0 +1,4 @@
+' . print_r($_SESSION, true) . ' ';
+echo 'Post variables:
' . print_r($_POST, true) . '
';
+?>
\ No newline at end of file
diff --git a/preferences.php b/preferences.php
index 1e46854..4df06c5 100644
--- a/preferences.php
+++ b/preferences.php
@@ -39,8 +39,6 @@ while ($row = $resacc->fetch_assoc()) {
echo '
';
// select which character from your GW account you want to default to
-echo 'the session prefaccid is: ' . $_SESSION['prefaccid'] . ' ';
-echo 'the session userid is: ' .$_SESSION['userid'] . ' ';
echo '
Current preferred character: ' .$_SESSION['prefcharname'] . '