diff --git a/changeaccounts.php b/changeaccounts.php deleted file mode 100644 index 112b62c..0000000 --- a/changeaccounts.php +++ /dev/null @@ -1,6 +0,0 @@ -user page'; -include_once ('footer.php'); -?> \ No newline at end of file diff --git a/includes/set-prefacc.php b/includes/set-prefacc.php new file mode 100644 index 0000000..0592145 --- /dev/null +++ b/includes/set-prefacc.php @@ -0,0 +1,25 @@ +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['prefaccname'] = "No default selected"; + echo 'Account preference update - no preferred account selected.
'; +} else { + $sap = $con->prepare("SELECT accid, accemail FROM gwaccounts WHERE accid = ? AND userid = ?"); + $sap->bind_param("ii", $_POST['prefaccid'], $_SESSION['userid']); + $sap->execute(); + $result = $sap->get_result(); + while ($row = $result->fetch_assoc()) { + $uap = $con->prepare("UPDATE userinfo SET prefaccid = ?, prefaccname = ? WHERE userid = ?"); + $uap->bind_param("isi", $_POST['prefaccid'], $row['accemail'], $_SESSION['userid']); + $uap->execute(); + $uap->close(); + $_SESSION['prefaccid'] = $row['accid']; + $_SESSION['prefaccname'] = $row['accemail']; + } + echo 'Guild Wars preferred account updated!
'; +} +?> \ No newline at end of file