| @@ -1,8 +1,8 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>Title Name</th><th>Title Type</th><th>Max Rank</th></tr>'; | |||
| echo '<form action="titlemanager.php" method="post"><table border="1"><tr><th>Title Name</th><th>Title Type</th><th>Max Rank</th><th>Auto filled?</th></tr>'; | |||
| echo '<tr><td><input type="text" name="titlename" placeholder="Friend of the Kurzicks" required autofocus></td><td style="text-align:left"><input type="radio" name="titletype" value="0" checked> Account<br /><input type="radio" name="titletype" value="1">Character</td>'; | |||
| echo '<td><input type="number" name="titlemaxrank" min="0" max="15"></td></tr>'; | |||
| echo '<td><input type="number" name="titlemaxrank" min="0" max="15"></td><td><input type="checkbox" name="autofill" value="1"></td></tr>'; | |||
| echo '</table><br /><input type="hidden" name="title" value="titlesubmit"><input type="submit" value="Add new title ..."></form>'; | |||
| } | |||
| ?> | |||
| @@ -1,7 +1,7 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| echo '<form action="titlemanager.php" method="post">'; | |||
| echo '<table border="1"><tr><th>titlenameid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th></tr>'; | |||
| echo '<table border="1"><tr><th>titlenameid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th><th>autofilled</th></tr>'; | |||
| $stmtview = $con->prepare("SELECT * FROM gwtitles WHERE titlenameid = ?"); | |||
| $stmtview->bind_param("i", $_POST['tid']); | |||
| $stmtview->execute(); | |||
| @@ -10,7 +10,8 @@ if (isset($_SESSION['userid'])) { | |||
| $tid = $row['titlenameid']; | |||
| $tname = $row['titlename']; | |||
| $ttype = $row['titletype']; | |||
| $tmr = $row['titlemaxrank']; | |||
| $tmr = $row['titlemaxrank']; | |||
| $taf = $row['autofilled']; | |||
| echo '<tr><td><input readonly size="3" name="titlenameid" value="' . $tid . '"></td><td><input size="40" type="text" name="titlename" value="' . $tname . '"></td><td style="text-align:left">'; | |||
| echo '<input type="radio" name="titletype" '; | |||
| if ($ttype == 0) { | |||
| @@ -21,7 +22,12 @@ if (isset($_SESSION['userid'])) { | |||
| if ($ttype == 1) { | |||
| echo 'checked '; | |||
| } | |||
| echo 'value="1">Character</td><td><input type="number" name="titlemaxrank" min="1" max="15" value="' . $tmr . '"></td></tr>'; | |||
| echo 'value="1">Character</td><td><input type="number" name="titlemaxrank" min="1" max="15" value="' . $tmr . '"></td><td>'; | |||
| echo '<input type="checkbox" name="autofill" value="' . $taf . '" '; | |||
| if ($taf == 1) { | |||
| echo 'checked'; | |||
| } | |||
| echo '></td></tr>'; | |||
| } | |||
| $stmtview->close(); | |||
| echo '</table><table><tr><th>Delete title?</th></tr><tr><td><input type="checkbox" name="deltitle" value="yes"></td></tr></table><br /><br />'; | |||
| @@ -1,7 +1,10 @@ | |||
| <?php | |||
| if (isset($_SESSION['userid'])) { | |||
| $stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank) VALUES (?, ?, ?)"); | |||
| $stmtins->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank']); | |||
| if (!isset($_POST['autofill'])) { | |||
| $_POST['autofill'] = "0"; | |||
| } | |||
| $stmtins = $con->prepare("INSERT INTO gwtitles (titlename, titletype, titlemaxrank, autofilled) VALUES (?, ?, ?, ?)"); | |||
| $stmtins->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill']); | |||
| $stmtins->execute(); | |||
| $stmtins->close(); | |||
| echo 'New title added!<br /><br />'; | |||
| @@ -12,9 +15,10 @@ if (isset($_SESSION['userid'])) { | |||
| $tid = $row['titlenameid']; | |||
| $tname = $row['titlename']; | |||
| $ttype = $row['titletype']; | |||
| $tmr = $row['titlemaxrank']; | |||
| echo '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th></tr>'; | |||
| echo '<tr><td>' . $tid . '</td><td>' . $tname . '</td><td>' . $ttype . '</td><td>' . $tmr . '</td></tr></table><br />'; | |||
| $tmr = $row['titlemaxrank']; | |||
| $taf = $row['autofilled']; | |||
| echo '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titlemaxrank</th><th>autofilled</th></tr>'; | |||
| echo '<tr><td>' . $tid . '</td><td>' . $tname . '</td><td>' . $ttype . '</td><td>' . $tmr . '</td><td>' . $taf . '</tr></table><br />'; | |||
| } | |||
| $stmtview->close(); | |||
| echo 'Return to <a href="titlemanager.php" class="navlink">title manager</a>'; | |||
| @@ -18,9 +18,12 @@ if (isset($_SESSION['userid'])) { | |||
| header ("Refresh:1; url=titlemanager.php"); | |||
| } | |||
| } else { | |||
| if (!isset($_POST['autofill'])) { | |||
| $_POST['autofill'] = "0"; | |||
| } | |||
| // this section updates the title name | |||
| $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ? WHERE titlenameid = ?"); | |||
| $stmtupd->bind_param("siii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['titlenameid']); | |||
| $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ?, titlemaxrank = ?, autofilled = ? WHERE titlenameid = ?"); | |||
| $stmtupd->bind_param("siiii", $_POST['titlename'], $_POST['titletype'], $_POST['titlemaxrank'], $_POST['autofill'], $_POST['titlenameid']); | |||
| $stmtupd->execute(); | |||
| $stmtupd->close(); | |||
| echo 'Title updated, redirecting!'; | |||
| @@ -50,7 +50,7 @@ if (isset($_SESSION['userid'])){ | |||
| echo '</select><noscript><input type="submit" value="Add title rank"></noscript></form><br /><br />'; | |||
| // now to view the last 5 title entries in the database | |||
| echo 'Here is the last 15 titles entered into the database, newest entry is on top:<br />'; | |||
| echo '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titletype</th></tr>'; | |||
| echo '<table border="1"><tr><th>titleid</th><th>titlename</th><th>titletype</th><th>titletype</th><th>autofilled</th><th>autofilled</th></tr>'; | |||
| $stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 15"); | |||
| $stmtview->execute(); | |||
| $result = $stmtview->get_result(); | |||
| @@ -59,6 +59,7 @@ if (isset($_SESSION['userid'])){ | |||
| $tname = $row['titlename']; | |||
| $ttype = $row['titletype']; | |||
| $tmr = $row['titlemaxrank']; | |||
| $taf = $row['autofilled']; | |||
| echo '<tr><td>' . $tid . '</td><td>' . $tname . ' (' . $tmr . ')</td><td>' . $ttype . '</td><td>'; | |||
| if ($ttype == "0") { | |||
| echo 'account'; | |||
| @@ -69,6 +70,16 @@ if (isset($_SESSION['userid'])){ | |||
| include_once ('footer.php'); | |||
| exit(); | |||
| } | |||
| echo '</td><td>' . $taf . '</td><td>'; | |||
| if ($taf == "0") { | |||
| echo 'no'; | |||
| } else if ($taf == "1") { | |||
| echo 'yes'; | |||
| } else { | |||
| echo 'Anything other than a 0 or 1 means something broke!'; | |||
| include_once ('footer.php'); | |||
| exit(); | |||
| } | |||
| echo '</td></tr>'; | |||
| } | |||
| $stmtview->close(); | |||