The article title
-Contents of the article element
-diff --git a/Website/class.user.php b/Website/class.user.php new file mode 100644 index 0000000..c41e3e8 --- /dev/null +++ b/Website/class.user.php @@ -0,0 +1,94 @@ +dbConnection(); + $this->conn = $db; + } + + public function runQuery($sql) + { + $stmt = $this->conn->prepare($sql); + return $stmt; + } + + public function register($uname,$upass) + { + try + { + //$new_password = password_hash($upass, PASSWORD_DEFAULT); // 3.2.17 ivan changed to cleartext password saving to make it more easy... + $new_password = $upass; + + $stmt = $this->conn->prepare("INSERT INTO users(user_name,user_pass) + VALUES(:uname, :upass)"); + + $stmt->bindparam(":uname", $uname); + $stmt->bindparam(":upass", $new_password); + + $stmt->execute(); + + return $stmt; + } + catch(PDOException $e) + { + echo $e->getMessage(); + } + } + + + public function doLogin($uname,$upass) + { + try + { + $stmt = $this->conn->prepare("SELECT user_id, user_name, user_pass FROM users WHERE user_name=:uname"); + $stmt->execute(array(':uname'=>$uname)); + $userRow=$stmt->fetch(PDO::FETCH_ASSOC); + if($stmt->rowCount() == 1) + { + //if(password_verify($upass, $userRow['user_pass'])) // 3.2.17 ivan changed to cleartext password saving to make it more easy... + if($upass == $userRow['user_pass']) + { + $_SESSION['user_session'] = $userRow['user_id']; + return true; + } + else + { + return false; + } + } + } + catch(PDOException $e) + { + echo $e->getMessage(); + } + } + + public function is_loggedin() + { + if(isset($_SESSION['user_session'])) + { + return true; + } + } + + public function redirect($url) + { + header("Location: $url"); + } + + public function doLogout() + { + session_destroy(); + unset($_SESSION['user_session']); + return true; + } +} +?> diff --git a/Website/dbconfig.php b/Website/dbconfig.php new file mode 100644 index 0000000..bbbf29d --- /dev/null +++ b/Website/dbconfig.php @@ -0,0 +1,27 @@ +conn = null; + try + { + $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password); + $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + catch(PDOException $exception) + { + echo "Connection error: " . $exception->getMessage(); + } + + return $this->conn; + } +} +?> diff --git a/Website/dblogin.sql b/Website/dblogin.sql new file mode 100644 index 0000000..c84be2d --- /dev/null +++ b/Website/dblogin.sql @@ -0,0 +1,39 @@ +-- phpMyAdmin SQL Dump +-- version 4.1.14 +-- http://www.phpmyadmin.net +-- +-- Host: 127.0.0.1 +-- Generation Time: Jan 07, 2016 at 03:05 AM +-- Server version: 5.6.17 +-- PHP Version: 5.5.12 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `dblogin` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `users` ( + `user_id` int(11) NOT NULL AUTO_INCREMENT, + `user_name` varchar(15) NOT NULL, + `user_pass` varchar(255) NOT NULL, + `joining_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Website/home.php b/Website/home.php new file mode 100644 index 0000000..a6cd2a3 --- /dev/null +++ b/Website/home.php @@ -0,0 +1,93 @@ +runQuery("SELECT * FROM users WHERE user_id=:user_id"); + $stmt->execute(array(":user_id"=>$user_id)); + + $userRow=$stmt->fetch(PDO::FETCH_ASSOC); + +?> + + +
+ + +User Home Page +
+
+ Programming Blog Featuring Tutorials on PHP, MySQL, Ajax, jQuery, Web Design and More...
+
+
+ tutorial link
+
+
Contents of the article element
-content or image
-Another Secure Profile Page
+
+ Programming Blog Featuring Tutorials on PHP, MySQL, Ajax, jQuery, Web Design and More...
+
+
+ tutorial link
+