Answer the question
In order to leave comments, you need to log in
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';
}
}
Answer the question
In order to leave comments, you need to log in
Modern PHP:
Antiquities:
$route = $_GET['route'] ?? '';
$route = isset($_GET['route']) ? $_GET['route'] : '';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question