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 '
'; @@ -47,22 +62,23 @@ while ($row = $result->fetch_assoc()) { $acclist->close(); echo '

'; -echo ''; -echo ''; -$lc = $con->prepare("SELECT charid, charname FROM gwchars WHERE accid = ?"); +echo '
Available characters
charidcharnameDelete?
'; +echo ''; +$lc = $con->prepare("SELECT charid, accid, charname FROM gwchars WHERE accid = ?"); $lc->bind_param("i", $_SESSION['prefaccid']); $lc->execute(); $res2 = $lc->get_result(); while ($row2 = $res2->fetch_assoc()) { - echo ''; + echo ''; + echo ''; } -echo '
Available characters
charidaccidcharnameDelete?
' . $row2['charid'] . ''; + echo '
'; if ($row2['charid'] == $_SESSION['prefcharid']) { echo '' . $row2['charname'] . ''; } else { echo $row2['charname']; } - echo '
'; +echo '

'; echo '
Return to your user page'; include_once ('footer.php'); ?> \ No newline at end of file diff --git a/addcharacters.php b/addcharacters.php index 14c50ac..7379645 100644 --- a/addcharacters.php +++ b/addcharacters.php @@ -2,7 +2,7 @@ $pagetitle = "Add Characters"; include_once ('header.php'); echo 'add a new character!'; -echo '
'; +echo '
'; echo ''; echo ''; echo '
Add character to account: ' . $_SESSION['prefaccname'] . '

'; diff --git a/style.css b/style.css index 2c4c3d5..8a8eedc 100644 --- a/style.css +++ b/style.css @@ -28,7 +28,7 @@ ul, li{ padding:0 0 0 15px; } -.column{ +.column { float: left; margin: 0 20px 0 0; } @@ -54,4 +54,10 @@ img.resize { input { text-align: center; +} + +input[type=submit] { + background-color: #4CAF50; + border: none; + color: white; } \ No newline at end of file