| @@ -3,12 +3,6 @@ $pagetitle = "Add a Guild Wars account to track"; | |||||
| include_once ('header.php'); | include_once ('header.php'); | ||||
| if (isset($_SESSION['userid'])){ | 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'])) { | if (!empty($_POST['accemail'])) { | ||||
| $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); | $addacc = $con->prepare("INSERT INTO gwaccounts (userid, accemail) VALUES (?, ?)"); | ||||
| $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); | $addacc->bind_param("is", $_SESSION['userid'], $_POST['accemail']); | ||||
| @@ -50,7 +44,6 @@ echo '</table></form><br />'; | |||||
| echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>'; | echo '<table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current Guild Wars accounts</caption>'; | ||||
| echo '<tr><th>Account name</th></tr>'; | echo '<tr><th>Account name</th></tr>'; | ||||
| // 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 = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE userid = ?"); | ||||
| $acclist->bind_param("i", $_SESSION['userid']); | $acclist->bind_param("i", $_SESSION['userid']); | ||||
| $acclist->execute(); | $acclist->execute(); | ||||
| @@ -21,6 +21,12 @@ if (isset($_SESSION['userid'])) { | |||||
| $_SESSION['prefaccid'] = $row['accid']; | $_SESSION['prefaccid'] = $row['accid']; | ||||
| $_SESSION['prefaccname'] = $row['accemail']; | $_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! <br />'; | echo 'Guild Wars preferred account updated! <br />'; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,5 +1,27 @@ | |||||
| <?php | <?php | ||||
| if (isset($_SESSION['userid'])) { | if (isset($_SESSION['userid'])) { | ||||
| echo 'this is the set-prefchar.php file text!<br />'; | |||||
| 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.<br />'; | |||||
| } 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! <br />'; | |||||
| } | |||||
| } | } | ||||
| ?> | ?> | ||||
| @@ -23,7 +23,7 @@ if (!empty($_POST['setchar'])) { | |||||
| include_once ('includes/set-prefchar.php'); | include_once ('includes/set-prefchar.php'); | ||||
| } | } | ||||
| echo '<h3>Change e-mail or password</h3>'; | |||||
| echo '<h3>Set preferred account & character, or change e-mail or password</h3>'; | |||||
| // select which GW account you want to default to | // select which GW account you want to default to | ||||
| echo '<form action="preferences.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current preferred account: <b>' .$_SESSION['prefaccname'] . '</b></caption>'; | echo '<form action="preferences.php" method="post"><table border="1"><caption style="white-space: nowrap; overflow: hidden;">Current preferred account: <b>' .$_SESSION['prefaccname'] . '</b></caption>'; | ||||
| @@ -52,7 +52,6 @@ while ($row2 = $reschar->fetch_assoc()) { | |||||
| echo '<option value="' . $row2['charid'] . '">' . $row2['charname'] . '</option>'; | echo '<option value="' . $row2['charid'] . '">' . $row2['charname'] . '</option>'; | ||||
| } | } | ||||
| echo '</td><td><input type="submit" value="Set character"></td></tr></select></table><input type="hidden" name="setchar" value="updatechar"></form><br />'; | echo '</td><td><input type="submit" value="Set character"></td></tr></select></table><input type="hidden" name="setchar" value="updatechar"></form><br />'; | ||||
| # needed code: select charrid from table gwchars selected by accid | |||||
| // update e-mail address form | // update e-mail address form | ||||
| echo '<form action="preferences.php" method="post"><table border="1">'; | echo '<form action="preferences.php" method="post"><table border="1">'; | ||||