Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Database {
- // properti
- private $dbHost="localhost";
- private $dbUser="root";
- private $dbPass="";
- private $dbName="angsuran";
- // method koneksi mysql
- function connectMySQL() {
- mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);
- mysql_select_db($this->dbName) or die ("Database Tidak Ditemukan di Server");
- }
- }
- class User {
- // Proses Login
- function cek_login($user, $password) {
- $password = md5($password);
- $result = mysql_query("SELECT * FROM admin WHERE user='$user' AND password='$password'");
- $user_data = mysql_fetch_array($result);
- $no_rows = mysql_num_rows($result);
- if ($no_rows == 1) {
- $_SESSION['login'] = TRUE;
- $_SESSION['id'] = $user_data['id'];
- return TRUE;
- }
- else {
- return FALSE;
- }
- }
- // Ambil Sesi
- function get_sesi() {
- return $_SESSION['login'];
- }
- // Logout
- function user_logout() {
- $_SESSION['login'] = FALSE;
- session_destroy();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement