diff --git a/addaccounts.php b/addaccounts.php index aaf139f..25975cb 100644 --- a/addaccounts.php +++ b/addaccounts.php @@ -3,12 +3,6 @@ $pagetitle = "Add a Guild Wars account to track"; include_once ('header.php'); if (isset($_SESSION['userid'])){ -# 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']); @@ -50,7 +44,6 @@ echo '
'; echo ''; echo ''; -// grab account name from database and loop it in here as a read only bit $acclist = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); $acclist->bind_param("i", $_SESSION['userid']); $acclist->execute(); diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php index eabe45d..57ffd59 100644 --- a/includes/set-prefacc.php +++ b/includes/set-prefacc.php @@ -21,6 +21,12 @@ if (isset($_SESSION['userid'])) { $_SESSION['prefaccid'] = $row['accid']; $_SESSION['prefaccname'] = $row['accemail']; } + $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 'Guild Wars preferred account updated!
'; } } diff --git a/includes/set-prefchar.php b/includes/set-prefchar.php index f640c5e..fa1b448 100644 --- a/includes/set-prefchar.php +++ b/includes/set-prefchar.php @@ -1,5 +1,27 @@ '; + if ($_POST['prefcharid'] == "nopref") { + $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 'Character preference update - no preferred character selected.
'; + } else { + $scp = $con->prepare("SELECT charid, charname FROM gwchars WHERE charid = ? AND accid = ? AND userid = ?"); + $scp->bind_param("iii", $_POST['prefcharid'], $_SESSION['prefaccid'], $_SESSION['userid']); + $scp->execute(); + $result = $scp->get_result(); + while ($row = $result->fetch_assoc()) { + $uap = $con->prepare("UPDATE userinfo SET prefcharid = ?, prefcharname = ? WHERE userid = ?"); + $uap->bind_param("isi", $_POST['prefcharid'], $row['charname'], $_SESSION['userid']); + $uap->execute(); + $uap->close(); + $_SESSION['prefcharid'] = $row['charid']; + $_SESSION['prefcharname'] = $row['charname']; + } + echo 'Guild Wars preferred character updated!
'; + } } ?> \ No newline at end of file diff --git a/preferences.php b/preferences.php index 9664f27..1e46854 100644 --- a/preferences.php +++ b/preferences.php @@ -23,7 +23,7 @@ if (!empty($_POST['setchar'])) { include_once ('includes/set-prefchar.php'); } -echo '

Change e-mail or password

'; +echo '

Set preferred account & character, or change e-mail or password

'; // select which GW account you want to default to echo '
Current Guild Wars accounts
Account name
'; @@ -52,7 +52,6 @@ while ($row2 = $reschar->fetch_assoc()) { echo ''; } echo '
Current preferred account: ' .$_SESSION['prefaccname'] . '

'; -# needed code: select charrid from table gwchars selected by accid // update e-mail address form echo '
';