0

I have a Opencart 3.0.3.8 php 8.0. How can I fix this error?

PHP Warning: Undefined array key "admin-key" in /home/websitename/storage/modification/admin/controller/common/login.php on line 92

this is a line 92.

if ($this->request->post['admin-key'] != $this->config->get('config_adminkey')) {

see below complete code.

<file path="admin/controller/common/login.php">
    <operation>
        <search ><![CDATA[
        public function index() {
        ]]></search>
        <add position="after"><![CDATA[
        $data['config_adminkey'] = $this->config->get('config_adminkey');
    ]]></add>
    </operation>
    <operation>
        <search ><![CDATA[
        protected function validate() {
        ]]></search>
        <add position="after"><![CDATA[     
         if ($this->request->post['admin-key'] != $this->config->get('config_adminkey')) {
            header("Status: 404 Not Found");
            require  'view/template/extension/module/404.html';
            exit;

Jose Lora
  • 1,392
  • 4
  • 12
  • 18
Muhammad Mirza
  • 1
  • 1
  • 1
  • 1

1 Answers1

0

isset() Should fix your problem.

Change this line:

if ($this->request->post['admin-key'] != $this->config->get('config_adminkey'))

to this one

if (isset($_POST['admin-key']) !== isset($_GET['config_adminkey']))

Aqilhex
  • 115
  • 1
  • 2
  • 14