Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include 'config.inc.php';
- class login1 extends DB{
- public $username;
- public $password;
- public $checknum;
- public $inusername;
- public function checkifuseronline($inusername){
- $DB = new DB();
- $DB->connect();
- $this->inusername = $DB->secret($inusername);
- $getuser = $DB->prepare("SELECT * FROM users WHERE username=?");
- $getuser->bind_Param("s", $this->inusername);
- $getuser->execute();
- $getuser->store_result();
- $getuser->num_rows;
- $this->checknum = $getuser->num_rows;
- if($this->checknum == "1"){
- header("location: profile.php");
- echo $this->checknum;
- }else{
- }
- }
- public function login($username, $password){
- $DB = new DB();
- $DB->connect();
- $this->username = $DB->secret($username);
- $this->password = $DB->secret($password);
- $getuser = $DB->prepare("SELECT * FROM users WHERE username=? and password=?");
- $getuser->bind_Param("ss", $this->username, $this->password);
- $getuser->execute();
- $getuser->store_result();
- $getuser->num_rows;
- $this->checknum = $getuser->num_rows;
- if($this->checknum == "1"){
- $_SESSION['inuser'] = $this->username;
- header("location: profile.php");
- echo $this->checknum;
- }else{
- echo "Fel användarnamn eller lösenord.";
- }
- }
- public $firstname;
- public $lastname;
- public $username1;
- public $password1;
- public $email;
- public $birth;
- public $register_date;
- public $ip;
- public $userfound1;
- public $picture;
- public $rank;
- public $banned;
- public function register1($firstname, $lastname, $username1, $password1, $email, $birth, $register_date, $ip){
- $DB = new DB();
- $DB->connect();
- $this->id = "";
- $this->firstname = $DB->secret($firstname);
- $this->lastname = $DB->secret($lastname);
- $this->username1 = $DB->secret($username1);
- $this->password1 = $DB->secret($password1);
- $this->email = $DB->secret($email);
- $this->birth = $DB->secret($birth);
- $this->register_date = $DB->secret($register_date);
- $this->ip = $DB->secret($ip);
- $this->picture = "images/newuser.png";
- $this->rank = "0";
- $this->banned = "0";
- // checkar av om användaren redan finns
- $userfound = $DB->prepare("SELECT * FROM users WHERE username = ? or email = ?");
- $userfound->bind_Param("ss", $this->username, $this->email);
- $userfound->execute();
- $userfound->store_result();
- $userfound->num_rows;
- $this->userfound1 = $userfound->num_rows;
- if($this->userfound1 == "1"){
- echo "Användarnamnet eller emailen är redan registerad...";
- }else{
- // sätter in användaren i databasen
- $insertuser = $DB->prepare("INSERT INTO users (id, username, password, firstname, lastname, email, birth, picture, register_date, rank, banned, ip)VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
- $insertuser->bind_Param("ssssssssssss", $this->id, $this->username1, $this->password1, $this->firstname, $this->lastname, $this->email, $this->birth, $this->picture, $this->register_date, $this->rank, $this->banned, $this->ip);
- $insertuser->execute();
- if($this->userfound1 == "1"){
- echo "Du är nu registerad klicka <a href='index.php'>här</a> för att logga...";
- }
- }
- }
- public $onlinename;
- public $checkonline;
- public function getuserinfo($onlinename){
- $DB = new DB();
- $DB->connect();
- $this->onlinename = $DB->secret($onlinename);
- $stmt = $DB->prepare("SELECT * FROM users WHERE username = ?");
- $stmt->bind_Param("s", $this->onlinename);
- $stmt->execute();
- $stmt->store_result();
- $stmt->num_rows;
- $this->checkonline = $stmt->num_rows;
- if($this->checkonline == "1"){
- $stmt->bind_result($id, $username, $password, $firstname, $password, $email, $birth, $picture, $register_date, $rank, $banned, $ip);
- while($stmt->fetch()){
- }
- }else{
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement