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

(09-23-2020, 02:09 PM)remesses_thegreat Wrote:
(09-23-2020, 06:30 AM)Matleyx Wrote: I also tried your way, but still get the same result....

Always without post data....

Controller Test.php:
PHP Code:
<?php namespace App\Controllers;

class 
Test extends BaseController
{
public function 
index()
{
            var_dump($_POST);
            die();
            $request = \Config\Services::request();
            $name $request->getVar('name');
            $lastname $request->getVar('lastname');
            echo 'StarttestingName'.$name.'EndtestingName<br>';
            echo 'StarttestingLastname'.$lastname.'EndtestingLastname<br>';
            
            
return view('test_2');

}
//--------------------------------------------------------------------


Views test_2.php:
Code:
<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>

I Just Tried this and It works fine for me

Views/welcome_mesaage.php

<form method="post" action="<?php echo base_url('Home/test'); ?>" >
    <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>

Then Controllers/Home.php Like

<?php namespace App\Controllers;

class Home extends BaseController
{
public function index()
{
return view('welcome_message');
}

public function test(){

            $request = \Config\Services::request();
            $name = $request->getVar('name');
            $lastname = $request->getVar('lastname');

            echo 'StarttestingName'.$name.'EndtestingName<br>';
            echo 'StarttestingLastname'.$lastname.'EndtestingLastname<br>';
           
           
}

}

?>

In your code you call Test controller Class and not  Test function. I have my base url set to name of projectfolder Like: http://127.0.0.1/projectfolder' Also have rewriteBase as project Folder

I tried like you:
COntroller Home.php
PHP Code:
<?php namespace App\Controllers;

class 
Home extends BaseController
{
public function 
index()
{
return 
view('welcome_message');
}

public function 
test(){
            var_dump($_POST);
            die();
            $request = \Config\Services::request();
            $name $request->getVar('name');
            $lastname $request->getVar('lastname');

            echo 'StarttestingName'.$name.'EndtestingName<br>';
            echo 'StarttestingLastname'.$lastname.'EndtestingLastname<br>';
          
          
}

}

?>

Views welcome_message.php:

PHP Code:
<form method="post" action="<?php echo base_url('Home/test'); ?>" >
    <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

Config/routes.php:

PHP Code:
<?php namespace Config;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(SYSTEMPATH 'Config/Routes.php'))
{
    require 
SYSTEMPATH 'Config/Routes.php';
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
$routes->get('/''Home::index');
$routes->post('home/test''Home::test');
$routes->post('test''test::index');

//$routes->get('login', 'Auth::login');
//
//$routes->get('logout', 'Auth::logout');
//$routes->get('forgot_password', 'Auth::forgot_password');

/**
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
 * need it to be able to override any defaults in this file. Environment
 * based routes is one such time. require() additional route files here
 * to make that happen.
 *
 * You will have access to the $routes object within that file without
 * needing to reload it.
 */
if (file_exists(APPPATH 'Config/' ENVIRONMENT '/Routes.php'))
{
    require 
APPPATH 'Config/' ENVIRONMENT '/Routes.php';


The result is: nothing....
Ithink that i should rebuild my debian box.....
Reply


Messages In This Thread
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