0

I continue to get the following notice when I load this page.:

(!)Notice: Undefined index: clear

I'd appreciate any assistance in clearing this notice.

<?php require_once("../../includes/initialize.php"); ?>
<?php if (!$session->is_logged_in()) { redirect_to("login.php"); } ?>
<?php

  $logfile = SITE_ROOT.DS.'logs'.DS.'log.txt';

  if($_GET['clear'] == 'true') {
        file_put_contents($logfile, '');
      // Add the first log entry
      log_action('Logs Cleared', "by User ID {$session->user_id}");
    // redirect to this same page so that the URL won't 
    // have "clear=true" anymore
    redirect_to('logfile.php');
  }
?>

<h2>Log File</h2>

<p><a href="logfile.php?clear=true">Clear log file</a><p>
IRONSHARK
  • 1
  • 1
  • `if (isset($_GET['clear']) && $_GET['clear'] == 'true')` -- Also, this will probably be closed as duplicate quite soon. Probably even downvoted a few times. You might want to search the site first before asking very obvious questions. – Ghedipunk Oct 02 '15 at 23:47
  • I appreciate your prompt response along with providing the correct code. Please note that I did search on "Undefined Index", but still found the postings not as helpful as what you provided in your response. Thank you. – IRONSHARK Oct 03 '15 at 00:12

0 Answers0