Back Setelah Login

Hasbi · Nov 19, 2012
Mas, mau nanya nih. Saya punya web. Setelah login, user diarahkan ke home.php. Jika user menekan tombol back pada browser, saya pinginnya user tidak masuk ke halaman login lagi, melainkan tetap di home.php, seperti Facebook. Itu gimana ya?
Makasih sebelumnya
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Nov 20, 2012 · 0 Suka · 0 Tidak Suka
bisa lihat kode login yang sudah kamu buat?
0
Loading...
Hasbi · Nov 20, 2012 · 0 Suka · 0 Tidak Suka
<?
$email=$_POST['email'];
$pass=$_POST['pass'];
$domain=$_POST['domain'];
$userDom=$email.''.$domain;

$Conn=new Connection(DB_USER,DB_PASS,DB);
$Conn->Query("SELECT * FROM pegawai WHERE email= :usr");
$Conn->createConnection();
$Conn->bindFetch(':usr',$userDom);

if($Conn->getRow('NOMOR')!=''){
	if($Conn->getRow('PASSWORD')==$pass){
		//cek apakah staff kepegawaian
		$no=$Conn->getRow('NOMOR');
		if($Conn->getRow('STAFF')=='19'){
			header('Location: index.php?page=kepeg');
			$_SESSION['userKepeg']=$no;
			$_SESSION['nama']=$Conn->getRow('NAMA');
		}
		else{
			$Conn->Query("SELECT * FROM pegawai_tugas_tambahan WHERE pegawai='".$Conn->getRow('NOMOR')."'");
			$Conn->fetch();
			$jab = $Conn->getRow('JABATAN');
			$arrJab = array('2','3','7','111');
			if(in_array($jab,$arrJab)){
				header('Location: index.php?page=jurusan');
				$_SESSION['userJur']=$no;
			}
		}
	}
	else{
		header('Location: index.php?salah=pass');
	}
}
else{
	header('Location: index.php?salah=user');
}
?>
0
Loading...
Ellyx Christian · Dec 5, 2012 · 0 Suka · 0 Tidak Suka
pertama perbaiki dulu kode loginnya:
<?
session_start();
$email=$_POST['email'];
$pass=$_POST['pass'];
$domain=$_POST['domain'];
$userDom=$email.''.$domain;
 
$Conn=new Connection(DB_USER,DB_PASS,DB);
$Conn->Query("SELECT * FROM pegawai WHERE email= :usr");
$Conn->createConnection();
$Conn->bindFetch(':usr',$userDom);
 
if($Conn->getRow('NOMOR')!=''){
	if($Conn->getRow('PASSWORD')==$pass){
		//cek apakah staff kepegawaian
		$no=$Conn->getRow('NOMOR');
		if($Conn->getRow('STAFF')=='19'){
			// session dulu baru header
			$_SESSION['userKepeg']=$no;
			$_SESSION['nama']=$Conn->getRow('NAMA');
			header('Location: index.php?page=kepeg');
		}
		else{
			$Conn->Query("SELECT * FROM pegawai_tugas_tambahan WHERE pegawai='".$Conn->getRow('NOMOR')."'");
			$Conn->fetch();
			$jab = $Conn->getRow('JABATAN');
			$arrJab = array('2','3','7','111');
			if(in_array($jab,$arrJab)){
				$_SESSION['userJur']=$no;
				header('Location: index.php?page=jurusan');
			}
		}
	}
	else{
		header('Location: index.php?salah=pass');
	}
}
else{
	header('Location: index.php?salah=user');
}
?>
dihalaman login ditambahkan seperti ini:
<?php
session_start();
if(isset($_SESSION['userKepeg']) && $_SESSION['userKepeg']){
	header('Location: index.php?page=kepeg');
	exit;
}
if(isset($_SESSION['userJur']) && $_SESSION['userJur']){
	header('Location: index.php?page=jurusan');
	exit;
}