diff --git a/addaccounts.php b/addaccounts.php index 29ed9aa..a4e7b7b 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -19,6 +19,11 @@ if (isset($_SESSION['userid'])) { // this section contains the code to add a new game account to track include_once ('includes/addaccount-submit.php'); } + + if (!empty($_POST['delaccid'])) { + // this section containts the code to delete an account + include_once ('includes/del-account.php'); + } if (!empty($_POST['delcharid'])) { // this section contains code to delete the selected characters @@ -35,8 +40,8 @@ if (isset($_SESSION['userid'])) { echo ''; echo '
'; - echo ''; - echo ''; + echo '
Current Guild Wars accounts
Account namePreferred?
'; + echo ''; $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); @@ -47,10 +52,11 @@ if (isset($_SESSION['userid'])) { if ($row['accid'] == $_SESSION['prefaccid']) { echo ' checked'; } - echo '>'; + //delete account array in delaccid[] + echo '>'; } $acclist->close(); - echo '
Current Guild Wars accounts
Account namePreferred?Delete ?

'; + echo '
'; // add characters here echo '
'; diff --git a/adminlanding.php b/adminlanding.php index ef2840f..ba900e4 100644 --- a/adminlanding.php +++ b/adminlanding.php @@ -6,7 +6,8 @@ if (isset($_SESSION['userid'])){ unset($_SESSION['tid']); echo '
Welcome to the admin area!

'; echo 'Title creator / editor here (work in progress)

'; - echo 'User editor here (not working yet)
'; + echo 'User editor here (not working yet)

'; + include_once ('includes/session-dump.php'); } include_once ('footer.php'); ?> \ No newline at end of file diff --git a/includes/del-account.php b/includes/del-account.php new file mode 100644 index 0000000..1463964 --- /dev/null +++ b/includes/del-account.php @@ -0,0 +1,49 @@ +prepare("SELECT charid, accid FROM gwchars WHERE accid IN ($gaccid) AND userid = ?"); + $gci->bind_param("i", $_SESSION['userid']); + $gci->execute(); + $gciresults = $gci->get_result(); + while ($gcirow = $gciresults->fetch_assoc()) { + $delchar = $con->prepare("DELETE FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + $delchar->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); + $delchar->execute(); + $delchar->close(); + // $dac = Delete Account Stats + $dac = $con->prepare("DELETE FROM gwaccstats WHERE accid = ? AND userid = ?"); + $dac->bind_param("ii", $gcirow['accid'], $_SESSION['userid']); + $dac->execute(); + $dac->close();/* + // $dcs = Delete Character Stats + $dcs = $con->prepare("DELETE FROM gwcharstats WHERE charid = ? AND accid = ? AND userid = ?"); + $dcs->bind_param("iii", $gcirow['charid'], $gcirow['accid'], $_SESSION['userid']); + $dcs->execute(); + $dcs->close(); */ + } + $gci->close(); + //this should be the last SQL query to run! + $delacc = $con->prepare("DELETE FROM gwaccounts WHERE accid IN ($gaccid) AND userid = ?"); + $delacc->bind_param("i", $_SESSION['userid']); + $delacc->execute(); + $delacc->close(); + // $nap = No Account Preference + $nap = $con->prepare("UPDATE userinfo SET prefaccid = 0, prefaccname = 'No default selected' WHERE userid = ?"); + $nap->bind_param("i", $_SESSION['userid']); + $nap->execute(); + $nap->close(); + $_SESSION['prefaccid'] = "0"; + $_SESSION['preaccname'] = "No default selected"; + echo 'Account(s) deleted - no preferred account selected.

'; + // $ncp = No Character Preference + $ncp = $con->prepare("UPDATE userinfo SET prefcharid = 0, prefcharname = 'No default selected' WHERE userid = ?"); + $ncp->bind_param("i", $_SESSION['userid']); + $ncp->execute(); + $ncp->close(); + $_SESSION['prefcharid'] = "0"; + $_SESSION['prefcharname'] = "No default selected"; + echo 'All characters related to the account have been deleted - no preferred character selected.

'; +} +?> \ No newline at end of file