From b8b8aa27ea4d944f4b3a64a0bd29000c2c0c9bcb Mon Sep 17 00:00:00 2001 From: mauirixxx Date: Fri, 17 Aug 2018 10:15:55 -1000 Subject: [PATCH] initial back end support for auto populated titles --- includes/title-add.php | 4 ++-- includes/title-editor.php | 12 +++++++++--- includes/title-submit.php | 14 +++++++++----- includes/title-update.php | 7 +++++-- titlemanager.php | 13 ++++++++++++- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/includes/title-add.php b/includes/title-add.php index 6cc4b71..5ffd134 100644 --- a/includes/title-add.php +++ b/includes/title-add.php @@ -1,8 +1,8 @@ '; + echo '
Title NameTitle TypeMax Rank
'; echo ''; - echo ''; + echo ''; echo '
Title NameTitle TypeMax RankAuto filled?
Account
Character

'; } ?> \ No newline at end of file diff --git a/includes/title-editor.php b/includes/title-editor.php index de4fca7..d62ed49 100644 --- a/includes/title-editor.php +++ b/includes/title-editor.php @@ -1,7 +1,7 @@ '; - echo ''; + echo '
titlenameidtitlenametitletypetitlemaxrank
'; $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 ''; + echo 'value="1">Character'; } $stmtview->close(); echo '
titlenameidtitlenametitletypetitlemaxrankautofilled
'; echo 'Character
'; + echo '
Delete title?


'; diff --git a/includes/title-submit.php b/includes/title-submit.php index 0ad33f9..525f3e0 100644 --- a/includes/title-submit.php +++ b/includes/title-submit.php @@ -1,7 +1,10 @@ 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!

'; @@ -12,9 +15,10 @@ if (isset($_SESSION['userid'])) { $tid = $row['titlenameid']; $tname = $row['titlename']; $ttype = $row['titletype']; - $tmr = $row['titlemaxrank']; - echo ''; - echo '
titleidtitlenametitletypetitlemaxrank
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '

'; + $tmr = $row['titlemaxrank']; + $taf = $row['autofilled']; + echo ''; + echo '
titleidtitlenametitletypetitlemaxrankautofilled
' . $tid . '' . $tname . '' . $ttype . '' . $tmr . '' . $taf . '

'; } $stmtview->close(); echo 'Return to title manager'; diff --git a/includes/title-update.php b/includes/title-update.php index 8b8c6c5..d46ce3c 100644 --- a/includes/title-update.php +++ b/includes/title-update.php @@ -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!'; diff --git a/titlemanager.php b/titlemanager.php index 7a6e8ce..693f567 100644 --- a/titlemanager.php +++ b/titlemanager.php @@ -50,7 +50,7 @@ if (isset($_SESSION['userid'])){ echo '

'; // 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:
'; - echo ''; + echo '
titleidtitlenametitletypetitletype
'; $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 ''; } $stmtview->close();
titleidtitlenametitletypetitletypeautofilledautofilled
' . $tid . '' . $tname . ' (' . $tmr . ')' . $ttype . ''; if ($ttype == "0") { echo 'account'; @@ -69,6 +70,16 @@ if (isset($_SESSION['userid'])){ include_once ('footer.php'); exit(); } + echo '' . $taf . ''; + 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 '