Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] - Strange problem with POST data
#1

(This post was last modified: 09-28-2020, 05:09 AM by Matleyx.)

Hi guys..
I started a new project with ci4 (my first time with 4), and I have a problem that seems really stupid: I can't pass POST data between the view and the controller. I've done a lot of test, but I don't understand where the problem lies.

The controller Test.php:

Code:
<?php namespace App\Controllers;

use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\Response;

class Test extends BaseController
{

public function index()
{
            $response = service('response');       
            $request = service('request');
           
            echo $request->uri->getPath()."<br>";
            echo $request->getMethod()."<br>";
           
            if ($request->getVar('submit'))
                {
                    if (isset($_POST['name']))
                        {
                            echo "Nome: ".$_POST['name']."<br>";
                        }   
                    if (isset($_POST['lastname']))
                        {
                            echo "Cognome: ".$_POST['lastname'];
                        }
                    return view('test_1');
                } else
                    {
                        return view('test_2');
                    }
}

//--------------------------------------------------------------------

}

view test_1.php:

Code:
Test1 si post


view test_2.php

Code:
Test 2 nessun post
<form action="test" method="post">
    <input type="text" name="name" value="Mario" id="name">
    <input type="text" name="lastname" value="Rossi" id="lastname">
    <input type="submit" name="submit" value="submit" id="submit">
</form>

When i try to submit the form, in the response, i haven't any POST data and reopen test_2 view. This is the html source code:

Code:
test<br>get<br><!-- DEBUG-VIEW START 1 APPPATH/Config/../Views/test_2.php -->

Test 2 nessun post

<form action="test" method="post">

<input type="text" name="name" value="Mario" id="name">

<input type="text" name="lastname" value="Rossi" id="lastname">

<input type="submit" name="submit" value="submit" id="submit">

</form>

<!-- DEBUG-VIEW ENDED 1 APPPATH/Config/../Views/test_2.php -->



<script type="text/javascript" id="debugbar_loader" data-time="1600851974" src="[url=http://www.yiisupertest.com/?debugbar]http://www.yiisupertest.com/?debugbar[/url]"></script><script type="text/javascript" id="debugbar_dynamic_script"></script><style type="text/css" id="debugbar_dynamic_style"></style>

I don't understand where i s the problem....
If i try without codeigniter, with only php simple file, the post data works fine.
I followed this guide:https://guidaphp.it/base/variabili-superglobali and post data work.

I don't know how to do it anymore

any help is welcome
Reply


Messages In This Thread
[SOLVED] - Strange problem with POST data - by Matleyx - 09-23-2020, 02:08 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 02:36 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 03:08 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 04:17 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 04:40 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 06:30 AM
RE: Strange problem with POST data - by Matleyx - 09-24-2020, 07:46 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 07:16 AM
RE: Strange problem with POST data - by Matleyx - 09-23-2020, 07:26 AM
RE: Strange problem with POST data - by InsiteFX - 09-23-2020, 04:20 PM
RE: Strange problem with POST data - by InsiteFX - 09-24-2020, 08:53 AM
RE: Strange problem with POST data - by Matleyx - 09-24-2020, 10:53 PM
RE: Strange problem with POST data - by Matleyx - 09-25-2020, 02:59 AM
RE: Strange problem with POST data - by Matleyx - 09-25-2020, 06:01 AM
RE: Strange problem with POST data - by Matleyx - 09-25-2020, 11:41 AM
RE: Strange problem with POST data - by Matleyx - 09-25-2020, 01:52 PM
RE: Strange problem with POST data - by InsiteFX - 09-26-2020, 01:15 AM
RE: Strange problem with POST data - by Matleyx - 09-26-2020, 07:02 AM
RE: Strange problem with POST data - by Matleyx - 09-26-2020, 10:42 AM
RE: Strange problem with POST data - by InsiteFX - 09-26-2020, 12:35 PM
RE: Strange problem with POST data - by Matleyx - 09-26-2020, 10:31 PM
RE: Strange problem with POST data - by Matleyx - 09-27-2020, 02:40 AM
RE: Strange problem with POST data - by Matleyx - 09-27-2020, 05:46 AM
RE: Strange problem with POST data - by Matleyx - 09-27-2020, 09:52 AM
RE: Strange problem with POST data - by demyr - 09-27-2020, 01:19 PM
RE: Strange problem with POST data - by Matleyx - 09-28-2020, 12:05 AM
RE: Strange problem with POST data - by Matleyx - 09-28-2020, 02:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB