<?php
session_start();
include 'koneksi.php';
$userid = $_POST['user'];
$psw = $_POST['password'];
$op = $_GET['op'];
if($op=="in"){
$cek = mysql_query("select user.nama,user.password,aksi.url from tipe_user_aksi,aksi,user
where user.user='$userid' and password='$psw' and user.id=tipe_user_aksi.id_user and aksi.id = tipe_user_aksi.id_aksi");
if(mysql_num_rows($cek)==1){//jika berhasil akan bernilai 1
$c = mysql_fetch_array($cek);
$a=$c['url'];
header("location:".$a);
}else{
die("password salah <a href=\"javascript:history.back()\">kembali</a>");
}
}else if($op=="out"){
unset($_SESSION['user']);
header("location:login_a.php");
}
?>
<?php
session_start();
$url = ltrim($_SERVER['PHP_SELF'], '/');
$dataurl = mysql_fetch_array(mysql_query("select * from aksi where url='".$url."'"));
$akses = mysql_query("select * from tipe_user_aksi where id_aksi='".$dataurl['id']."' and id_user='".$_SESSION['user']."'");
if(mysql_num_rows($akses) <= 0){
echo 'Forbidden';
exit;
}
kemudian ubah kode login kamu jadi:<?php
session_start();
include 'koneksi.php';
$userid = mysql_real_escape_string($_POST['user']);
$psw = mysql_real_escape_string($_POST['password']);
$op = $_GET['op'];
if($op=="in"){
$cek = mysql_query("select * from user where user.user='$userid' and password='$psw'");
if(mysql_num_rows($cek)==1){//jika berhasil akan bernilai 1
$c = mysql_fetch_array($cek);
$_SESSION['user'] = $c['id'];
header("location: admin.php"); // atau ke halaman lain, sesuikan
}else{
die("password salah <a href=\"javascript:history.back()\">kembali</a>");
}
}else if($op=="out"){
unset($_SESSION['user']);
header("location:login_a.php");
}
?>
<?php
session_start();
include 'koneksi.php';
$userid = mysql_real_escape_string($_POST['user']);
$psw = mysql_real_escape_string($_POST['password']);
$op = $_GET['op'];
if($op=="in"){
$cek = mysql_query("select * from user where user.user='$userid' and password='$psw'");
if(mysql_num_rows($cek)==1){//jika berhasil akan bernilai 1
$c = mysql_fetch_array($cek);
$_SESSION['user'] = $c['id'];
header("location: home_admin.php"); // atau ke halaman lain, sesuikan
}else{
die("password salah <a href=\"javascript:history.back()\">kembali</a>");
}
}else if($op=="out"){
unset($_SESSION['user']);
header("location:login_a.php");
}
?>
<?php
session_start();
$url = ltrim($_SERVER['PHP_SELF'], '/');
$dataurl = mysql_fetch_array(mysql_query("select * from aksi where url='".$url."'"));
$akses = mysql_query("select * from tipe_user_aksi where id_aksi='".$dataurl['id']."' and id_user='".$_SESSION['user']."'");
if(mysql_num_rows($akses) <= 0){
echo 'Forbidden';
exit;
}
?>
<?php
session_start();
include 'koneksi.php';
$url = ltrim($_SERVER['PHP_SELF'], '/');
$dataurl = mysql_fetch_array(mysql_query("select * from aksi where url='".$url."'"));
$akses = mysql_query("select * from tipe_user_aksi where id_aksi='".$dataurl['id']."' and id_user='".$_SESSION['user']."'");
if(mysql_num_rows($akses) <= 0){
echo 'Forbidden';
exit;
}
?>
<?php
session_start();
include 'koneksi.php';
$url = ltrim($_SERVER['PHP_SELF'], '/');
die($url); //untuk debug
$dataurl = mysql_fetch_array(mysql_query("select * from aksi where url='".$url."'"));
$akses = mysql_query("select * from tipe_user_aksi where id_aksi='".$dataurl['id']."' and id_user='".$_SESSION['user']."'");
if(mysql_num_rows($akses) <= 0){
echo 'Forbidden';
exit;
}
?>
kemudian cocokan url-nya dengan data yang ada didatabase. <?php
session_start();
include 'koneksi.php';
$arrayCurrentPath = explode('?',$_SERVER['REQUEST_URI']);
$url = substr($arrayCurrentPath[0], strlen(BASE_URL));
$dataurl = mysql_fetch_array(mysql_query("select * from aksi where url='".$url."'"));
$akses = mysql_query("select * from tipe_user_aksi where id_aksi='".$dataurl['id']."' and id_user='".$_SESSION['user']."'");
if(mysql_num_rows($akses) <= 0){
echo 'Forbidden';
exit;
}
?>