mas Ellyx aku nanya gimana cara membatasi login, seumpama user login 3x salah terus, maka firefox secara auto akan nutup mas, tolong mas ?
ini scrip login aku
<?php 
	session_start(); 
	mysql_connect("localhost","root","") or die("Nggak bisa koneksi"); 
	mysql_select_db("spk");//sesuaikan dengan nama database anda 
	 
	$userid = $_POST['userid']; 
	$psw = $_POST['psw']; 
	$op = $_GET['op']; 
	 
	if($op=="in"){ 
	    $cek = mysql_query("SELECT * FROM login WHERE nama='$userid' AND password='$psw'"); 
	    if(mysql_num_rows($cek)==1){ 
	        $c = mysql_fetch_array($cek); 
	        $_SESSION['userid'] = $c['userid']; 
	        $_SESSION['level'] = $c['level']; 
	        if($c['level']=="admin"){ 
	            header("location:home.php"); 
	        }else if($c['level']=="user"){ 
	            header("location:home.php"); 
	        } 
	    }else{ 
	         die("password salah <a href=\"javascript:history.back()\">kembali</a>");
			 header("location:index.php") ;
	    } 
	}else if($op=="out"){ 
	    unset($_SESSION['userid']); 
	    unset($_SESSION['level']); 
	    header("location:index.php"); 
	} 
?> 
Silahkan login untuk menjawab!
0
Loading...
Aryox · Nov 19, 2012 · 0 Suka · 0 Tidak Suka
seperti ini mas scripnya, tp ini masih error :(
<?php session_start();
    $userid = $_POST['userid']; 
    $psw = $_POST['psw']; 
    $op = $_GET['op']; 

    if($op=="in"){
$cek = mysql_query("SELECT * FROM login WHERE nama='$userid' AND password='$psw'");
    if(mysql_num_rows($cek)>0){
      $c = mysql_fetch_array($cek);
      $_SESSION['userid'] = $c['userid'];
      $_SESSION['level'] = $c['level'];

      if($c['level']=="admin")
         header("location:adminhome.php");
      else
         header("location:userhome.php");
   }else{
     if($_COOKIE['warning_count'] && $_COOKIE['warning_count']<3){
        setcookie('warning_count' ,$_COOKIE['warning_count']+1);
    }else if ($_COOKIE['warning_count'] && $_COOKIE['warning_count']==3)
        $msg_warning = "Maaf... Anda sudah 3x salah login, silakan cobaa lagi besok!";
     }else {
        setcookie ('warning_count',1);
     }
   }
}
?>