daily pastebin goal
29%
SHARE
TWEET

Untitled

mdmasudhasan Feb 19th, 2019 101 in 3 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     class database
  4.     {
  5.         public $connect ;
  6.         public function __construct()
  7.         {
  8.             $connect= new PDO("mysql:host=localhost;dbname=coders","root","");
  9.             $this->connect=$connect ;
  10.         }
  11.  
  12.         public function login($user,$pass)
  13.         {
  14.             $takeAll = "SELECT * FROM users WHERE username=:user AND password=:pass";
  15.             $st = $this->connect->prepare($takeAll);
  16.             $st->execute(
  17.                     array(
  18.                         ':user'=> $user,
  19.                         ':pass'=> md5($pass)
  20.                     )
  21.                 );
  22.             $res=$st->fetchAll();
  23.             return count($res);
  24.         }
  25.  
  26.         public function reg($name,$pass,$email,$batch)
  27.         {
  28.             $pass = md5($pass);
  29.             $insert_query = "INSERT INTO users (username,password,email) VALUES(:name,:pass,:email)";
  30.             $inset_query1 = "INSERT INTO students (name,email,batch) VALUES (:name,:email,:batch)";
  31.             $st = $this->connect->prepare($insert_query);
  32.             $st1 = $this->connect->prepare($inset_query1);
  33.             $st->bindparam(':name',$name);
  34.             $st->bindparam(':pass',$pass);
  35.             $st->bindparam(':email',$email);
  36.             $st1->bindparam(':name',$name);
  37.             $st1->bindparam(':email',$email);
  38.             $st1->bindparam(':batch',$batch);
  39.             $st->execute();
  40.             $st1->execute();
  41.  
  42.             header("location:log.php");
  43.         }
  44.  
  45.         public function view()
  46.         {
  47.             $takeAll = "SELECT * FROM students";
  48.             $st = $this->connect->prepare($takeAll);
  49.             $st->execute();
  50.             $result = $st->fetchAll();
  51.  
  52.             return $result;
  53.         }
  54.  
  55.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top