D
D
Denis2021-01-05 19:49:44
PHP
Denis, 2021-01-05 19:49:44

How to remove the error - Notice: Undefined index: route in /Applications/MAMP/htdocs/eshop/index.php on line 2?

Help to remove the error:
Notice: Undefined index: route in /Applications/MAMP/htdocs/eshop/index.php on line 2
Platform: MAMP (php 7.4.12)
How to remove this error?

.htaccess
=======================
RewriteEngine On
RewriteBase /eshop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !- f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /eshop/index.php?route=$1 [L]
==================== ===
Index.php

<?php
$route = $_GET['route'];
if ($route == '' or $route == '/') {
    require_once 'main.php';
} else if ($route == 'admin') {
    require_once 'admin.php';
} else if ($route == 'admin-create') {
    require_once 'admin_create.php';
} else if ($route == 'login') {
    require_once 'login.php';
} else {
    $route = explode("/", $route);
    if ($route[0] == 'admin-update') {
        $_GET['id'] = $route[1];
        require_once 'admin_update.php';
    }
    if ($route[0] == 'cat') {
        $_GET['id'] = $route[1];
        require_once 'category.php';
    } else if ($route[0] == 'arcticle') {
        $_GET['id'] = $route[1];
        require_once 'arcticle.php';
    }
}


And on the site all the links without the "eshop" folder. For example: localhost/admin.php , but I want it to be localhost/eshop/admin.php . I would like to resolve this!
I would be grateful for your help, otherwise I have been walking in three pines for the second hour!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Ezhgurov, 2021-01-05
@Cobra8106

Modern PHP: Antiquities:
$route = $_GET['route'] ?? '';

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

Your $_GET['route'] element does not exist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question