Welcome Guest, Not a member yet? Register   Sign In
GET query doesn't work
#1

(This post was last modified: 08-07-2024, 03:31 AM by Ñuño Martínez.)

I'm trying to use GET parameters in an URL (for example myserver.com/acontroler/?alias=q) but it doesn't work.

First it raised a BadRequestException #400 because it has disallowed characters, but adding "?&=" to $permittedURIChars returns a "404-Page not found" error.
What I'm doing wrong?  Shouldn't CI parse GET parameters by itself?
Reply
#2

Can you show us your code so we can help?
Reply
#3

Cannot reproduce.

app/Config/Routes.php
PHP Code:
<?php

use CodeIgniter\Router\RouteCollection;

$routes->get('acontroler''Home::index'); 

app/Controllers/Home.php
PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function index(): string
    
{
        dd($this->request->getGet());
    }


Code:
$ php spark serve

Navigate to http://localhost:8080/acontroler/?alias=q
Code:
$this->request->getGet() array (1)

    ⇄alias => string (1) "q"

⧉ Called from .../app/Controllers/Home.php:9 [dd()]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB