-2

anyone can help me? i used this code for managing pages and it's get

undefined index : page
undefined index : aksi

<?php
$page = $_GET['page'];
$aksi = $_GET['aksi'];
if($page == "") {
    if($aksi == "") {
        include "page/dashboard.php";
    }
} elseif($page == "dashboard") {
    if($aksi == "") {
         include "page/dashboard.php";
    }
}elseif($page == "masuk") {
    if($aksi == "") {
         include "page/kas_masuk/masuk.php";
    }
    if($aksi == "hapus") {
         include "page/kas_masuk/hapus.php";
    }
}
?>
Qirel
  • 25,449
  • 7
  • 45
  • 62
trisna
  • 1

1 Answers1

-1

Use isset() function like below,

UPDATE

To get value of $_GET[] use below

$page = (isset($_GET['page'])?$_GET['page']:'');
$aksi = (isset($_GET['aksi'])?$_GET['aksi']:'');

Now we will get value if $_GET[] have value otherwise empty without returning any error or warning

KMS
  • 566
  • 4
  • 16
  • 1
    That gives you something completely different - a boolean, depending on whether or not those GET parameter exist, but not their _values_ if they do. – CBroe Sep 19 '17 at 09:09
  • the error dissapear, but now it wont change page, just change the address bar with the same page – trisna Sep 19 '17 at 09:13
  • @CBroe First i added the code for removing that given `undefined index` error. Now i changed the code to get value if it is there – KMS Sep 19 '17 at 09:29