diff --git a/includes/title-select.php b/includes/title-select.php new file mode 100644 index 0000000..f274625 --- /dev/null +++ b/includes/title-select.php @@ -0,0 +1,11 @@ +prepare("SELECT * FROM gwtitles ORDER BY titlename"); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + echo ''; +} +$stmtview->close(); +?> \ No newline at end of file diff --git a/includes/title-submit.php b/includes/title-submit.php new file mode 100644 index 0000000..cef8a57 --- /dev/null +++ b/includes/title-submit.php @@ -0,0 +1,19 @@ +prepare("INSERT INTO gwtitles (titlename, titletype) VALUES (?, ?)"); +$stmtins->bind_param("si", $_POST['titlename'], $_POST['titletype']); +$stmtins->execute(); +$stmtins->close(); +echo 'New title added!

'; +$stmtview = $con->prepare("SELECT * FROM gwtitles ORDER BY titlenameid DESC LIMIT 1"); +$stmtview->execute(); +$result = $stmtview->get_result(); +while ($row = $result->fetch_assoc()) { + $tid = $row['titlenameid']; + $tname = $row['titlename']; + $ttype = $row['titletype']; + echo ''; + echo '
titleidtitlenametitletype
' . $tid . '' . $tname . '' . $ttype . '

'; +} +$stmtview->close(); +echo 'Return to title manager'; +?> \ No newline at end of file diff --git a/includes/title-update.php b/includes/title-update.php new file mode 100644 index 0000000..4773de2 --- /dev/null +++ b/includes/title-update.php @@ -0,0 +1,26 @@ +Please check the box to verify you want to delete: ' . $_POST['titlename'] . ' '; + echo '

'; + } else if ($_POST['deltitle'] == "iamsure") { + // this section actually deletes the title + $stmtdel = $con->prepare("DELETE FROM gwtitles WHERE titlenameid = ?"); + $stmtdel->bind_param("i", $_POST['titlenameid']); + $stmtdel->execute(); + $stmtdel->close(); + echo 'Title has been deleted, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); + } +} else { + // this section updates the title name + $stmtupd = $con->prepare("UPDATE gwtitles SET titlename = ?, titletype = ? WHERE titlenameid = ?"); + $stmtupd->bind_param("sii", $_POST['titlename'], $_POST['titletype'], $_POST['titlenameid']); + $stmtupd->execute(); + $stmtupd->close(); + echo 'Title updated, redirecting!'; + header ("Refresh:1; url=titlemanager.php"); +} +//echo 'Return to title manager'; //this line needs to go away soon +?> \ No newline at end of file diff --git a/includes/verifications.php b/includes/verifications.php new file mode 100644 index 0000000..24f4d06 --- /dev/null +++ b/includes/verifications.php @@ -0,0 +1,55 @@ += 1) { + echo '
This e-mail address is already registered, please click on the forgot password link.
Please try again!

'; + include_once ('footer.php'); + exit(); + } +} + +# this function verifies that a username doesn't already exist in the database +function validateUsername($uname) { + $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); + $sqlunamecheck = "SELECT username FROM userinfo WHERE userinfo.username = '" . $uname . "'"; + $results = mysqli_query($con, $sqlunamecheck); + if (mysqli_num_rows($results) >= 1) { + echo '
This username has already been taken, please choose another one
Please try again!
'; + include_once ('footer.php'); + exit(); + } +} + +#################### +# verifying the username doesn't already exist in the database +$username = mysqli_real_escape_string($con, $_POST['username']); +validateUsername($username); + +#################### +# verifying the e-mail address is in a valid format +$verifyemail = validateEmail($_POST['useremail']); +if (empty($verifyemail)) { + echo '
This address: ' . $_POST['useremail'] . ' is not a valid e-mail address!
Please verify and type it again.
'; + include_once ('footer.php'); + exit(); +} + +usedEmail($_POST['useremail']); + +#################### +# verifying passwords match each other + +if (($_POST['userpass1']) != ($_POST['userpass2'])) { + echo '
The passwords don\'t match!
Please try again!'; + include_once ('footer.php'); + exit(); +} +?> \ No newline at end of file