Advertisement
cakmoel

login.php

May 18th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. include '../conn/conn.php;
  4.  
  5. function select($sql, $param = array(), $fetchMode = PDO::FETCH_ASSOC){
  6.    
  7.   global $koneksi;
  8.  
  9.         $stmt = $koneksi->prepare($sql);
  10.         foreach($param as $key => $value){
  11.             if(is_int($value)){
  12.                 $stmt->bindValue("$key", $value, PDO::PARAM_INT);
  13.             } else {
  14.                 $stmt->bindValue("$key", $value);
  15.             }
  16.         }
  17.  
  18.         $stmt->execute();
  19.         return $stmt->fetchAll($fetchMode);
  20.     }
  21.  
  22. // cara penerapan
  23. session_start();
  24. $user = $_POST['user'];
  25. $pass = md5($_POST['pass']);
  26. $view = select("select * from user where username= :username", array(':username' => $user));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement