SHARE
TWEET

kinda works :o

a guest Feb 4th, 2016 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Connect
  3. {
  4.     public function __construct()
  5.     {
  6.         try
  7.             {
  8.                 $this->db = new PDO("mysql:host=localhost;dbname=aaron_test",'aaron_test','d6G4X5S54');
  9.             }
  10.         catch(PDOException $e)
  11.         {
  12.             echo $e->getMessage();
  13.         }
  14.     }
  15.  
  16.     public function login($name, $pass)
  17.     {
  18.         if(!empty($name) && !empty($pass))
  19.         {
  20.             $st = $this->db->prepare("SELECT * FROM users WHERE username= ? and password= ?");
  21.             $st->bindParam(1, $name);
  22.             $st->bindParam(2, $pass);
  23.             $st->execute();
  24.  
  25.             if($st->rowCount() == 1)
  26.             {
  27.                 echo "Access Granted.";
  28.             }
  29.             else
  30.                 {
  31.                     echo "incorrect username or password.";
  32.                 }
  33.         }  
  34.         else
  35.             {
  36.                 echo "Please supply a username and password.";
  37.             }
  38.     }
  39.  
  40. }
  41.  
  42. if(isset($_POST['submit']))
  43. {
  44.     $name = $_POST['user'];
  45.     $pass = $_POST['pass'];
  46.  
  47.     $object = new Connect();
  48.     $object->login($name, $pass);
  49. }
  50.  ?>
  51.  
  52.  
  53.  
  54.  <form action="" method="POST">
  55.     Username: <input type="text" name="user">
  56.     Password: <input type="text" name="password">
  57.     <input type="submit" name="submit" value="Login">
  58.  </form>
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