我收到通知:当我将变量传递给另一个页面时,未定义的索引[重复]

I am trying to pass a variable from one page to another using a URL but I get a NOTICE. I have read that NOTICE or WARNINGS can be suppressed, by I want to learn how to fix this if possible. Thanks!

Notice: Undefined index: status in /view_dept.php on line 139

this is the URL and where the query happens - (technically the page1 - where the variable comes from):

header('location:view_dept.php?status=success');

This is the "page2", where I need to pass the variable so I can echo a success message. This is the MAIN PAGE.

<?php
    if( $_GET['status'] == 'success'):
        echo 'SUCCESS';
    endif;
?>
</div>

To avoid the Notice, try isset() to check if the index status is present

<?php
if( isset($_GET['status']) && $_GET['status'] == 'success'):
    echo 'SUCCESS';
endif;
?>