-2

Before I was hosting there were no problems, after I upload them to appear 000webhost notice "Use of undefined constant login - assumed 'login' in /storage/ssd4/109/2310109/public_html/surat/login.php on line 26"

        if (isset($_POST[login])){
        $user = $_POST['user'];
        $pass = md5($_POST['pass']);
        $login=mysql_query("SELECT * FROM phpmu_user
            WHERE username='$user' AND password='$pass' AND status='Y'");
        $cocok=mysql_num_rows($login);
        $r=mysql_fetch_array($login);

        if ($cocok > 0){
            $_SESSION[login]        = $r[id_user];
            $_SESSION[username]     = $r[username];
            $_SESSION[namalengkap]  = $r[nama_lengkap];
            $_SESSION[password]     = $r[password];
            $_SESSION[level]        = $r[level];
            $_SESSION[unit]        = $r[unit_kerja];

            header('location:index.php');
        }else{
            echo "<script>window.alert('Maaf, Anda Tidak Memiliki akses');
                    window.location=('index.php')</script>";
        }
    }
  • 2
    Possible duplicate of [What does the PHP error message "Notice: Use of undefined constant" mean?](https://stackoverflow.com/questions/2941169/what-does-the-php-error-message-notice-use-of-undefined-constant-mean) – Progman Sep 10 '17 at 17:07

1 Answers1

1

Because php can't know if login is a key, or a variable.

2 solutions :

 if (isset($_POST['login'])){

Or ...

 if (isset($_POST[$login])){

But in your case, I think it's a key. And same problem with your $_SESSION array.

Jerry
  • 1,141
  • 1
  • 13
  • 18