N
N
Nick Bukovskiy2017-09-06 15:03:01
PHP
Nick Bukovskiy, 2017-09-06 15:03:01

How can I write routing on slim?

There is a task on the slim to write api. Method for user login and adding pictures.
I wrote a login html and a class with a method that logs in. How can I connect this in routing?
To be displayed when typing /login html form and after sending refer to my login verification method

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maksim Kochkin, 2017-09-14
@MaxxArts

GET request will get the login form, POST will log in. The form should accordingly have method=post.
$app = new \Slim\App();
$app->get('/login', function ($request, $response, $args) {
// login page
});
$app->post('/login', function ($request, $response, $args) {
// do login, redirect to main page
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question