The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

Variables are always empty?

NBG's Avatar


31 Jul, 2015 03:38 PM


i'm new to Slim and just playing around with handling forms...


<form action="cart" method="post">
<input type="hidden" name="product" value="foo">
<input type="submit" value="Add to cart">
require 'Slim/Slim.php';
$app = new \Slim\Slim();
$allGetVars = $app->request->post();
$app->post('/cart',function(){echo $allGetVars['product'];});
Why is the array always empty?


  1. Support Staff 1 Posted by Andrew Smith on 01 Aug, 2015 02:19 PM

    Andrew Smith's Avatar

    You would need to call that inside of the actual route.

    $app = new \Slim\Slim();
    $app->post('/cart',function() {
        $allGetVars = $app->request->post();
        echo $allGetVars['product'];

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac