Fishing in uncharted waters, I gave klein.php routing a spin and can't for the life of me find out how to pass a $_POST from a html form to another view.
Example:
index.php
<?php
//START ROUTING
require 'klein.php';
require 'autoload.php';
respond('/', function ($request, $response) {
$response->render('homepage.php', array(
'meta_title' => 'My Homepage'
));
});
respond('/[:name]', function ($request, $response) {
$response->render('siteinfo.php', array(
'meta_title' => 'My Details Page'
));
});
Now, I have a form on homepage.php where I do the following:
<form method="post">
<input type="text" name="url">
<button type="submit">Submit</button>
</form>
siteinfo.php grabs whatever is passed after the url (i.e. example.com/product123 -> product123) and displays information about that in the view "siteinfo.php". So far this works perfectly with the above code if entered manually into the address bar, since I can access [:name] as $request->name on siteinfo.php.
Whenever I trigger a search on the form, I'd like to pass the $_POST from the homepage.php view to index.php as [:name] without $_GET! Any idea how this works with klein.php or where I should start looking for answers?
I have tried to pass the param() value too, but this still does not work with the form. I have also tried adding action=index.php/siteinfo.php/homepage.php as the form's action, but still no love...
Any help much apprechiated ...
This would be a good place to start. What have you tried so far?