JSFiddle - React, Tailwind, and code Playground

by Dennis Betman

HTML

<?php
// Start Session
session_start();

// Every public function is listed in one class
class jewelbeastUserSystem {
	public $currentUser;
	public $users_table;
	public $username_field;
	public $password_field;
	protected $_query;
	protected $_numRows;
	protected $_fetchArray;
	
	public function __construct() {
		// Initialize MySQL Database
		// Enter your database login details here (Host, Login, Password) followed by the Database name
		mysql_connect('localhost', 'root', '');
		mysql_select_db('jewelbeast');

		// The table and fields used. This can be set up with an existing user database.
		$this->users_table = 'users';
		$this->username_field = 'username';
		$this->password_field = 'password';
		$this->banned = 'banned';
		$this->activated = 'active';
		$this->userLevel = 'userlevel';

		$this->standardLevel = '728956';
		
		// Initialize user if signed in
		if(isset($_SESSION['user'])) {
			$query = $this->query("SELECT * FROM `".$this->users_table."` WHERE `".$this->username_field."` = '".$_SESSION['user']."';");
			if($this->_numRows == 1) {
				$this->currentUser = $_SESSION['user'];
			}
		}
	}

	// Safer Query function. Mostly used for Update queries. Feel free to use this as your general Query.
	public function safeQuery($query) {
		mysql_real_escape_string($query);
		$args = array_slice(func_get_args(),1);
		$args = array_map(array($this, 'safeQuery'),$args);
		return mysql_query(vsprintf($query,$args));
	}

	// General Query
	public function query($sql) {
		$this->_query = mysql_query($sql);
		$this->_numRows = mysql_num_rows($this->_query);
		$this->_fetchArray = mysql_fetch_assoc($this->_query);
	}
	
	// String sanitize
	public function sanitize($string) {
		$string = mysql_real_escape_string($string);
		return $string;
	}

	// Safe redirect
	public function redirect($url) {
		header('location:'.$url);
		exit;
	}

	// Get Database row
	public function getRow($table, $row = "", $id = "1", $where = "") {
		$this->query("SELECT * FROM `".$table."`...