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

Slim Login using Post or Get methods

Kieran's Avatar


14 Jun, 2012 07:58 AM

Hey guys,
I'm very new to using Slim so bare with me.

I'm using Slim to create a restful service to pick back data and create json objects for an app using Android - so far so good.

Next thing is creating a login page: I've been having trouble with sending parameters using my get method which is something like


Does anyone have an example of using a POST method in slim or an example of a generic login using it.


  1. Support Staff 1 Posted by Brian Nesbitt on 18 Jun, 2012 06:38 PM

    Brian Nesbitt's Avatar

    Using the URI to send login credentials is probably not a great idea. Assuming you don't actually have the user id of the user logging in and you are submitting username/password you could just try something like:



    $app->post('/user/login', function ($username, $password) { // todo : authenticate user });

    You could use the urlFor() function to generate the form action.

  2. 2 Posted by Jonathan Markev... on 19 Jun, 2012 12:42 PM

    Jonathan Markevich's Avatar

    Did some of that view code get stripped out?

  3. Support Staff 3 Posted by Brian Nesbitt on 19 Jun, 2012 02:14 PM

    Brian Nesbitt's Avatar

    Uh ya... let me try that again!


    <form action="/user/login" method="POST">
       <input type="text" name="username" id="username" />
       <input type="password" name="password" id="password" />
       <input type="submit" value="Login" />


    $app->post('/user/login', function () use ($app) {
       //todo : authenticate user from post variables

    You could use the urlFor() function to generate the form action.

  4. 4 Posted by kierandes on 19 Jun, 2012 02:29 PM

    kierandes's Avatar

    Thanks for that! Must try that later

  5. Brian Nesbitt closed this discussion on 29 Jun, 2012 01:09 PM.

Comments are currently closed for this discussion. You can start a new one.

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