Advertisement
thebys

PreparedMeh

Apr 13th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. include_once "php/session.php";
  3. include_once 'php/sqlite.php';
  4.  
  5. if (isset($_POST["passphrase"])) {
  6.     try {
  7.         $dbh = new PDO('sqlite:db/mdytdb');
  8.         $dbh -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  9.     } catch(PDOException $e) {
  10.         print 'Exception : ' . $e -> getMessage();
  11.     }
  12.     $stmt = $dbh -> prepare("SELECT * FROM uzivatele WHERE jmeno = :jmeno AND heslo = :heslo LIMIT 1");
  13.     $hash = crypt($_POST["passphrase"], '$2y$08$dvacetdvaznakuosumosum$');
  14.     $stmt -> bindParam(':jmeno', $_POST["username"]);
  15.     $stmt -> bindParam(':heslo', $hash);
  16.     $stmt -> execute();
  17. //protože PDO rowCount() v nasazený verzi php nefunguje:
  18.     $rows = $stmt -> fetchAll();
  19.     $rowsCount = count($rows);
  20.     if ($rowsCount == 1) {
  21.         echo "Login OK.";
  22.     } else {
  23.         echo "Login Not OK.";
  24.     }
  25.     terminateSQLite();
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement