diff --git a/addaccounts.php b/addaccounts.php
index b2ca3ba..4b01219 100644
--- a/addaccounts.php
+++ b/addaccounts.php
@@ -2,6 +2,12 @@
$pagetitle = "Add a Guild Wars account to track";
include_once ('header.php');
+# delete this block when shit finally works.
+ini_set('display_errors', 'on');
+error_reporting(E_ALL);
+mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+# delete the above when shit finally works
+
if (!empty($_POST['accemail'])) {
$addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)");
$addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']);
@@ -14,13 +20,22 @@ if (!empty($_POST['accemail'])) {
if (!empty($_POST['delchar'])) {
echo 'removing selected character(s) from selected account
';
- $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?");
- $delchar->bind_param("iii", $_POST['charid'], $_POST['accid'], $_SESSION['userid']);
- $delchar->execute();
- $delchar->close();
- echo 'Need to figure out code to delete stats related to this character still!
';
- //header ("Refresh:1; url=addacounts.php");
- //exit();
+ 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();
+ }
+ $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.
';
}
echo '