if (empty($newPass)) { $passError = "Error, password cannot be left blank."; } else { $passError = ""; } if (empty($newConfirmPass)) { $passConfirmError = "Error, please confirm password."; } else { $passConfirmError = ""; } if ($newPass !== $newConfirmPass && !empty($newConfirmPass) && !empty($newPass)) { $passError = "Error, Passwords do not match."; $passConfirmError = ""; } $query = mysqli_prepare($conn, "SELECT * FROM members WHERE username = ? or email = ?"); $result_of_login_check = bindFetch($query, [$newName, $newEmail]); if (count($result_of_login_check) != 0) { $nameError = "There is already a user with that name."; } if ($nameError == "" && $passError == "" && $passConfirmError == "" && count($result_of_login_check) == 0) { $newPassHash = password_hash($newPass, PASSWORD_DEFAULT); $insertQuery = mysqli_prepare($conn, "INSERT INTO members (`username`, `pwHash`, `email`) VALUES (?, ?, ?)"); $result_of_insert_check = bindExecute($insertQuery, [$newName, $newPassHash, $newEmail]); //$retval = mysqli_query($conn, "INSERT INTO members (`id`, `username`, `password`, `email`) VALUES (NULL, '$newName', '$newPass', '$newEmail')"); if (!$result_of_insert_check) { die('Could not update data: ' . mysqli_error($conn)); } else { echo ' <form method="post" id="registerSuccess" name="form3" action="index.php"> <p>Registration successfull.</p><br> <input type="hidden" id="myusername" name="user_name" value="' . $newName . '"/>
/** * simply return the current state of the user's login * @return boolean user's login status */ public function isUserLoggedIn() { require_once "config/gv.php"; if (isset($_COOKIE["UUID"])) { if ($_COOKIE["UUID"] != "") { $userConn = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME); $getUUIDsql = mysqli_prepare($userConn, "SELECT uuid, gv FROM members WHERE uuid = ?"); $result = bindFetch($getUUIDsql, [$_COOKIE["UUID"]]); if (count($result) <= 0) { // UUID's do not match. return false; } else { $gvs = json_decode($result[0]['gv']); // create time was over 4 hours ago if ($gvs->timeStamp <= time() - TIMEOUT) { $delete_UUID_query = mysqli_prepare($userConn, "UPDATE `members` SET `gv`='', `uuid`='' WHERE `uuid`=?"); $resultDelete = bindExecute($delete_UUID_query, [$_COOKIE['UUID']]); mysqli_stmt_close($delete_UUID_query); unsetGV(); setcookie("UUID", "", time() - 99999); return false; } else { $gvs->timeStamp = time(); foreach ($gvs as $key => $val) { $GLOBALS[$key] = $val; } $update_GV_Query = mysqli_prepare($userConn, "UPDATE `members` SET `gv`=?, `timeStamp`=now() WHERE `uuid`=?"); $resultUpdate = bindExecute($update_GV_Query, [json_encode($gvs), $_COOKIE["UUID"]]); mysqli_stmt_close($update_GV_Query); return true; } } $userConn->close(); } } return false; }