6

I'm migrating from codeigniter to Fat-Free (F3) and trying to get my head around the quirks.

Regarding the following form:

<form ACTION = "<?php echo $_SERVER['PHP_SELF'];?>" METHOD="POST">
  <input type="text" name="theirName" value="" required="required">
    ...

In standard PHP I get the POST value like this:

$name = $_POST['theirName'];

Or in codeignitor:

echo form_open('someclass/some_method_of_someclass');
$name = $this->input->post('name');

How do I get data from a form in a view in f3/fatfree?

lorem monkey
  • 3,942
  • 3
  • 35
  • 49
user2984700
  • 73
  • 2
  • 9
  • there are some useful tutorials on the web that include forms, example [blog-tutorial-with-fat-free-framework](http://www.willis-owen.co.uk/2011/09/blog-tutorial-with-fat-free-framework/) – Ryan Vincent May 10 '14 at 19:24
  • This seems to work in passing data from a route to a route: $f3->route('GET /form', function($f3){ echo '
    '; echo 'login: '; echo ''; echo '
    '; } ); ....................................... $f3->route('POST /auth', function($f3) { echo $f3->get('POST.getData'); } ); auth seems to be a built in method
    – user2984700 May 10 '14 at 19:44
  • sorry for the confusion, the model they use has 'copyFrom' feature. i suggest just using $_POST directly. However, if you validate the input in a model that just use that model in the view. – Ryan Vincent May 10 '14 at 20:36
  • cheers Ryan somebody else has posted similar question- so added to their post:http://stackoverflow.com/questions/20855847/mailing-a-form-fat-free-framework/23591576#23591576. I think I can underatnd the form bit; the next problem is understanding how to use $smtp = new SMTP('mail.pickaweb.co.uk', – user2984700 May 11 '14 at 10:43

1 Answers1

12

You can get it from the Hive:

$name = $f3->get('POST.name');
lorem monkey
  • 3,942
  • 3
  • 35
  • 49
Nilam Sari
  • 136
  • 1
  • 3
  • how to you post json data with vanilla js ? I tried this , but teh adta do not show up in the hive : ```var r = new XMLHttpRequest(); r.open("POST", "/staticpage/update", true); r.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); r.onreadystatechange = function () { if (r.readyState != 4 || r.status != 200) return; alert("Success: " + r.responseText); }; r.send( json );``` ps: it ios a share that commenst look so ugly on a coding platfrom like this here – daslicht Oct 11 '18 at 18:18