Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- What is the best way to protect my DB class from being hacked [closed]
- class dbinterface {
- private $_dbLink;
- private $dbHost = 'host';
- private $dbUser = 'user';
- private $dbName = 'name';
- private $dbPass = 'pass';
- private $dbUserTable = 'table';
- public function connect ()
- {
- $this->_dbLink = mysql_connect($this->_dbHost, $this->_dbUser, $this->_dbPass);
- if(!$this->_dbLink)
- throw new Exception ("Could not connect to database. " . mysql_error());
- }
- function registerUser($userName, $userPassword) {
- $db = new db();
- $db->connect();
- // Select database
- mysql_select_db($this->dbName);
- $query = "insert into usersExample values (NULL, "$userName", "$userPassword")";
- $result = mysql_query($query);
- // Test to make sure query worked
- if(!$result) die("Query didn't work. " . mysql_error());
- // Get the user ID
- $this->userID = mysql_insert_id();
- // Close database connection
- mysql_close($dbLink);
- } // End registerUser()
- <?php defined('IN_APP') or die('No access allowed.');
- define('IN_APP', true);
Add Comment
Please, Sign In to add comment