Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

CripDawg

Member
  • Content Count

    133
  • Joined

  • Last visited

Awards


This user doesn't have any awards

2 Followers

About CripDawg

  • Title
    Member
  • Birthday 1997-05-04

Profile Information

  • Gender
    Male
  • Location
    Australia

System

  • CPU
    AMD 8350 (4.00Ghz)
  • Motherboard
    ASUS M5A97 R2.0
  • RAM
    G.Skill Sniper 8GB DDR3
  • GPU
    XFX R9 280X 3GB
  • Case
    Corsair 300R
  • Storage
    120GB 840 EVO 1TB Seagate Barracuda
  • PSU
    600W Strider Silverstone
  • Display(s)
    23" HP Monitor, 32" Samsung TV
  • Cooling
    Noctua NH-U14S
  • Keyboard
    Thermaltake Ultimate Challenger
  • Operating System
    Windows 7 64-bit
  1. Cheers for the advice I'll probably just go with whatever replaces the 3950X then, I will also be using this PC for VM's on occasion so the extra cores will be helpful... Correct me if I'm wrong?
  2. Hi Guys, I've decided I will be building a PC in the coming months, I will be waiting for the 3080 Ti. Not to sure whether to wait for the Ryzen 4000 or get a 3950X. Recently I've seen the news that the Ryzen 4000's will only be available in prebuilt systems, not to sure if this means they will be waiting to release the high end flagship models later on? Question is should I wait if the 4000 series flagships are not released around the same time as the 3080 Ti, or should i just buy a 3950X instead?. Thanks for the advice in advance. :)
  3. after my computer was turned off by being pulled out from the power point I'm getting this error 0xc000000f the boot selection because a required device is inaccessible i tried going into the BIOS and was unsuccessful Windows 7 on a 120gb 840 EVO SSD the rest of the specs can be found on my forum profile
  4. i need help doing a structure chart for my webpage witch consists of a login and shopping cart system i have attempted to make one but my teacher says that it needs to be less like a flowchart and i am also wondering whats some good software besides Microsoft word because it doesn't have the type of arrows used to represent the flow of data. Any help or advice is appreciated
  5. where about in my code would i put that also i would prefer something that goes along with the code in the tutorial so i continue it because I'm almost finished it
  6. when i click the logout button nothing happens where it should delete the session and then redirect to index.php witch should the echo 'you need to login or register' but nothing happens
  7. but I've gone so far with this and it seems to be exactly what i need so i would see it as a big waste of time if i was to start again
  8. could you maybe direct some people who might be able to help to this post please?
  9. how do i do that and do you have any idea how to fix my problem
  10. my login and register pages are working fine just a logout button that isn't working I'm watching a oop tutorial on youtube and I'm unto this part I've tried some debugging that other forms have said i should do like the error log line but still no result sorry for attaching so much code but i feel that its necessary because their are a fair amount of methods that relate to the logout and some of them are on different files User.php <?phpclass User {private $_db,$_data,$_sessionName,$_isLoggedIn; public function __construct($user = null) {$this->_db = DB::getInstance(); $this->_sessionName = Config::get('session/session_name'); error_log("session name: ".$this->_sessionName); if(!$user) {if(Session::exists($this->_sessionName)) {$user = Session::get($this->_sessionName); if($this->find($user)) {$this->_isLoggedIn = true;} else {//process logout}}} else {$this->find($user);}} public function create($fields = array()) {if (!$this->_db->insert('users', $fields)) {throw new Exception('there was a problem creating your account');}} public function find($user = null) {if($user) {$field = (is_numeric($user)) ? 'id' : 'username';$data = $this->_db->get('users', array($field, '=', $user)); if($data->count()) {$this->_data = $data->first();return true;}}return false;} public function login($username = null, $password = null){$user = $this->find($username); if($user) {if($this->data()->password === Hash::make($password, $this->data()->salt)) {Session::put($this->_sessionName, $this->data()->id);return true;}} return false;} public function logout() {Session::delete($this->_sessionName);} public function data() {return $this->_data;} public function isLoggedIn() {return $this->_isLoggedIn;}} index.php <?phprequire_once 'core/init.php'; if(Session::exists('home')) {'<p>' . Session::flash('home') . '</p>';} $user = new User();if($user->isLoggedIn()) {?><p>Hello <a href="#"><?php echo escape($user->data()->username); ?> </a></p> <ul><li><a href="logout.php">Log out</a></li></ul> <?php} else {echo '<p>You need to <a href="login.php">Log In</a> or <a href="register.php">Register</a></p>';} DB.php <?phpclass DB {private static $_instance = null;private $_pdo,$_query, $_error = false, $_results, $_count = 0; private function __construct() {try {$this->_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password'));} catch(PDOException $e) {die($e->getMessage());}} public static function getInstance() {if(!isset(self:_instance)) {self:_instance = new DB();}return self:_instance;} public function query($sql, $params = array()) {$this->_error = false;if($this->_query = $this->_pdo->prepare($sql)) {$x = 1; if(count($params)) { foreach($params as $param) { $this->_query->bindValue($x, $param); $x++; } } if($this->_query->execute()) { $this->_results = $this->_query->fetchALL(PDO::FETCH_OBJ); $this->_count = $this->_query->rowCount(); } else { $this->_error = true; }} return $this;} public function action($action, $table, $where = array()){if(count($where)=== 3) {$operators = array('=', '>', '<', '>=', '<='); $field = $where[0];$operator = $where[1];$value = $where[2]; if(in_array($operator, $operators)) {$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?"; if(!$this->query($sql, array($value))->error()) {return $this;} }} return false; } public function get($table, $where) {return $this->action('SELECT *', $table, $where);} public function delete($table, $where) {return $this->action('DELETE', $table, $where);} public function insert($table, $fields = array()) {$keys = array_keys($fields);$values = '';$x = 1; foreach($fields as $field) {$values .= "?";if($x < count($fields)) {$values .= ', '; }$x++;} $sql = "INSERT INTO users (`" . implode('`, `', $keys) . "`) VALUES ({$values})"; if(!$this->query($sql, $fields)->error()) {return true; } return false;} public function update($table, $id, $fields) {$set = '';$x = 1; foreach($fields as $name => $value){$set .= "{$name} = ?";if($x < count($fields)){$set .= ', '; }$x++;} $sql = "UPDATE {$table} SET {$set} WHERE id = {$id}"; if(!$this->query($sql, $fields)->error()) {return true; } } public function results() {return $this->_results;} public function first() {return $this->results()[0];} public function error() {return $this->_error;} public function count() {return $this->_count;} } logout.php <?phprequire_once 'core/init.php'; $user = new User();$user->logout(); Redirect::to('index.php'); Session.php <?phpclass Session {public static function exists($name) {return (isset($_SESSION[$name])) ? true : false;} public static function put($name, $value) {return $_SESSION[$name] = $value;} public static function get($name) {return $_SESSION[$name];} public static function delete($name) {if(self::exists($_SESSION[$name])) {unset($_SESSION[$name]);}} public static function flash($name, $string = '') {if (self:: exists($name)) {$session = self::get($name);self::delete($name);return $session;} else {self::put($name, $string);}}}
  11. did a quick google......is that being able to call private variables outside of a class eg user and session variables? i know there is a constructor in user.php if i login with the correct details it redirects me from login.php therefore the Redirecting is not the problem if i delete the session cookie manually and refresh my browser it says you need to login or register as it should and my href in index.php is correct then ether my logout function on user.php or my delete function in DB.php are incorrect an i on the right track with finding the issue i trust you already found it you just want me to find it myself
  12. it creates a new user object so that i can pull stuff from the user class
  13. ok ill give it a shot it will probably be wrong though haha im just copying a video series <?phprequire_once 'core/init.php'; $user = new User(); //not to sure what this line does $user->logout(); // this runs the logout method in User.php witch uses the delete function in DB.php to delete the session of the user Redirect::to('index.php'); //redirect to index.php using the to function in Redirect witch will display you need to login or register because there is not a valid session anymore DB.php <?phpclass DB {private static $_instance = null;private $_pdo,$_query, $_error = false, $_results, $_count = 0; private function __construct() {try {$this->_pdo = new PDO('mysql:host=' . Config::get('mysql/host') . ';dbname=' . Config::get('mysql/db'), Config::get('mysql/username'), Config::get('mysql/password'));} catch(PDOException $e) {die($e->getMessage());}} public static function getInstance() {if(!isset(self:_instance)) {self:_instance = new DB();}return self:_instance;} public function query($sql, $params = array()) {$this->_error = false;if($this->_query = $this->_pdo->prepare($sql)) {$x = 1; if(count($params)) { foreach($params as $param) { $this->_query->bindValue($x, $param); $x++; } } if($this->_query->execute()) { $this->_results = $this->_query->fetchALL(PDO::FETCH_OBJ); $this->_count = $this->_query->rowCount(); } else { $this->_error = true; }} return $this;} public function action($action, $table, $where = array()){if(count($where)=== 3) {$operators = array('=', '>', '<', '>=', '<='); $field = $where[0];$operator = $where[1];$value = $where[2]; if(in_array($operator, $operators)) {$sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?"; if(!$this->query($sql, array($value))->error()) {return $this;} }} return false; } public function get($table, $where) {return $this->action('SELECT *', $table, $where);} public function delete($table, $where) {return $this->action('DELETE', $table, $where);} public function insert($table, $fields = array()) {$keys = array_keys($fields);$values = '';$x = 1; foreach($fields as $field) {$values .= "?";if($x < count($fields)) {$values .= ', '; }$x++;} $sql = "INSERT INTO users (`" . implode('`, `', $keys) . "`) VALUES ({$values})"; if(!$this->query($sql, $fields)->error()) {return true; } return false;} public function update($table, $id, $fields) {$set = '';$x = 1; foreach($fields as $name => $value){$set .= "{$name} = ?";if($x < count($fields)){$set .= ', '; }$x++;} $sql = "UPDATE {$table} SET {$set} WHERE id = {$id}"; if(!$this->query($sql, $fields)->error()) {return true; } } public function results() {return $this->_results;} public function first() {return $this->results()[0];} public function error() {return $this->_error;} public function count() {return $this->_count;} } User.php <?phpclass User {private $_db,$_data,$_sessionName,$_isLoggedIn; public function __construct($user = null) {$this->_db = DB::getInstance(); $this->_sessionName = Config::get('session/session_name'); if(!$user) {if(Session::exists($this->_sessionName)) {$user = Session::get($this->_sessionName); if($this->find($user)) {$this->_isLoggedIn = true;} else {//process logout}}} else {$this->find($user);}} public function create($fields = array()) {if (!$this->_db->insert('users', $fields)) {throw new Exception('there was a problem creating your account');}} public function find($user = null) {if($user) {$field = (is_numeric($user)) ? 'id' : 'username';$data = $this->_db->get('users', array($field, '=', $user)); if($data->count()) {$this->_data = $data->first();return true;}}} public function login($username = null, $password = null){$user = $this->find($username); if($user) {if($this->data()->password === Hash::make($password, $this->data()->salt)) {Session::put($this->_sessionName, $this->data()->id);return true;}} return false;} public function logout() {Session::delete($this->_sessionName);} public function data() {return $this->_data;} public function isLoggedIn() {return $this->_isLoggedIn;}} Redirect.php <?phpclass Redirect {public static function to($location = null) {if($location) {if(is_numeric($location)) {switch($location) {case 404:header('HTTP/1.0 404 Not Found');include 'includes/errors/404.php';exit();break;}}header('Location: ' . $location);exit();}}}
  14. should have done code blocks sorry I've checked the to methods delete, to and login and made sure my href line has the correct file name Session.php <?phpclass Session {public static function exists($name) {return (isset($_SESSION[$name])) ? true : false;} public static function put($name, $value) {return $_SESSION[$name] = $value;} public static function get($name) {return $_SESSION[$name];} public static function delete($name) {if(self::exists($_SESSION[$name])) {unset($_SESSION[$name]);}} public static function flash($name, $string = '') {if (self:: exists($name)) {$session = self::get($name);self::delete($name);return $session;} else {self::put($name, $string);}}} logout.php <?phprequire_once 'core/init.php'; $user = new User();$user->logout(); Redirect::to('index.php'); index.php <?phprequire_once 'core/init.php'; if(Session::exists('home')) {'<p>' . Session::flash('home') . '</p>';} $user = new User();if($user->isLoggedIn()) {?><p>Hello <a href="#"><?php echo escape($user->data()->username); ?> </a></p> <ul><li><a href="logout.php">Log out</a></li></ul><?php} else {echo '<p>You need to <a href="login.php">Log In</a> or <a href="register.php">Register</a></p>';}
×