Skip to content

Instantly share code, notes, and snippets.

@wichaksono
Created April 18, 2016 07:12
Show Gist options
  • Save wichaksono/fb55f0b7b0a01ca8db8d2a0707c7316e to your computer and use it in GitHub Desktop.
Save wichaksono/fb55f0b7b0a01ca8db8d2a0707c7316e to your computer and use it in GitHub Desktop.
<?php
session_start();
require 'config.php';
if(isset($_POST['username']) && isset($_POST['password']))
{
$sql_check = "SELECT nama,
level_user,
id_user
FROM users
WHERE
username=?
AND
password=?
LIMIT 1";
$check_log = $dbconnect->prepare($sql_check);
$check_log->bind_param('ss', $username, $password);
$username = $_POST['username'];
$password = md5($_POST['password']);
$check_log->execute();
$check_log->store_result();
if ($check_log->num_rows == 1)
{
$check_log->bind_result($nama, $level_user, $id_user);
while ($check_log->fetch())
{
$_SESSION['user_login'] = $level_user;
$_SESSION['sess_id'] = $id_user;
$_SESSION['nama'] = $nama;
}
$check_log->close();
header('location:on-'.$level_user);
exit();
}
else
{
header('location: login.php?error='.base64_encode('Username dan Password Invalid!!!'));
exit();
}
} else {
header('location:login.php');
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment