All, something similar seems to have been posted before, however, slim and twig are still very new to me so apologies.
A little back ground, I have an application which posts data to
http://dev.website.com/post.php
Data1="My Date"
Data2="More data"
Eventually it will go in the database, but baby steps, first i just want to know then when i run the post from something like Advanced REST client, it actually shows its been posted.
In old school PHP I can just do this:
<?php
print ("Data1: " . $_POST["Data1"]);
print ("Data2: " . $_POST["Data2"]);
?>
Im trying to do this in slim and twig but I either don't understand it correctly or its not working, could someone tell me what im doing wrong please?
Im using userfrosting for a start which seems to work, i've done the tutorials on the site but they dont really help with this.
in the site index, my routes in index.php look like this:
$app->get('/post.php', function () use ($app) {
$app->render('post.twig');
});
$app->post('/post.php', function () use ($app) {
$backup_post_data1= $app->request->post('data1');
$app->render('post.twig', [
'backup_post_data1' => $backup_post_data1,
]);
});
My twig template post.php (That's what it was called in the old PHP site and is hard coded in the application which makes the post)
{% extends "layouts/layout-simple.twig" %}
{% block page %}
{% set page = page | merge({
"title" : "post page",
"description" : "Accept new data from post."
}) %}
{{ parent() }}
{% endblock %}
{% block content %}
<h1>My data</h1>
<table border="1">
<tbody>
<tr>
<td><strong> Variable</strong></td>
<td><strong> POST DATA </strong></td>
</tr>
<tr>
<td>
Data1
</td>
<td>
{{ backup_post_data1 }}
</td>
</tr>
</tbody>
</table>
{% endblock %}
Thanks in advance