Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Auth
- {
- public $con;
- function __construct()
- {
- $host = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'logout';
- $this->con = new mysqli($host, $user, $pass, $db) or die($con->error);
- }
- public function login($user = null, $pass = null) {
- $query = $this->con->prepare("SELECT * FROM `t_user` WHERE `username` = ? && `password` = MD5(?)");
- $query->bind_param('ss', $user, $pass);
- $query->execute();
- $query->store_result();
- $total = $query->num_rows();
- $query->bind_result($id, $user, $fullname,$password);
- $query->fetch();
- if ($total > 0)
- {
- //set_session
- $_SESSION['iduser'] = $id;
- $_SESSION['is_login'] = TRUE;
- } else {
- echo '<script type="text/javascript">alert("Akun tidak dikenali")</script>';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement