Posts: 39
Threads: 10
Joined: May 2016
Dear community,
Currently I have a PHP file in the theme folder where I post my form data to for processing. This seems to be incorrect to me so I am wondering if a kind soul could inform me of the "correct" way to handle form post data in getsimple CMS?
I am going then via plugin display the data in the backend.
Posts: 1,247
Threads: 82
Joined: Feb 2011
Posts: 39
Threads: 10
Joined: May 2016
2019-03-05, 21:59:40
(This post was last modified: 2019-03-05, 22:00:30 by vish93.)
(2019-03-05, 21:51:27)datiswous Wrote: There's a form plugin: http://get-simple.info/extend/plugin/imforms/1121/
Came across it yesterday but not really suitable for what I am after. You also have to run at least PHP 5.6.0 on your server.
I have in a new theme.php file created my form that I will display. Then collect the responses and show in backend admin plugin page.
I just need to figure what is the correct way in getSimpleCMS to handle ajax posts, as a php file in my theme folder doesn't seem the best solution.
Posts: 538
Threads: 12
Joined: May 2013
2019-03-05, 22:40:27
(This post was last modified: 2019-03-05, 22:46:58 by Bigin.)
(2019-03-05, 21:59:40)vish93 Wrote: Came across it yesterday but not really suitable for what I am after. You also have to run at least PHP 5.6.0 on your server.
- Yeah, but only because you don't really have a clue how that works ;-)
You can use
ItemManager to do this.
It can process and save the data coming from your form for you.
PS. ItemManager requires at least PHP 5.6.0, you are right.
Posts: 39
Threads: 10
Joined: May 2016
(2019-03-05, 22:40:27)Bigin Wrote: (2019-03-05, 21:59:40)vish93 Wrote: Came across it yesterday but not really suitable for what I am after. You also have to run at least PHP 5.6.0 on your server.
- Yeah, but only because you don't really have a clue how that works ;-)
You can use ItemManager to do this.
It can process and save the data coming from your form for you.
PS. ItemManager requires at least PHP 5.6.0, you are right.
Unfortunately CentosOS does only support 5.4 in official repo.
Posts: 538
Threads: 12
Joined: May 2013
Posts: 305
Threads: 15
Joined: Mar 2014
@vish93
If you are going to do it with your own plugin (which would indeed be better than in the theme folder),
GS provides some functions for handling AJAX together with auth (
requestIsAjax
,
get_cookie
, and
check_nonce
)
I do AJAX saving in my plugin Components Extended (see my signature below), you can look at the code for inspiration, see this excerpt for example:
PHP Code:
$global $USR;
if (requestIsAjax()) {
// protect against CSRF, basic check
if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME'))
die();
// only continue if the request comes from the same domain & nonces match
if (empty($_GET['nonce']) || !check_nonce($_GET['nonce'], 'components_ext_action', 'components_ext.php'))
die();
}
Posts: 39
Threads: 10
Joined: May 2016
(2019-03-07, 09:26:06)Tyblitz Wrote: @vish93
If you are going to do it with your own plugin (which would indeed be better than in the theme folder),
GS provides some functions for handling AJAX together with auth (requestIsAjax
, get_cookie
, and check_nonce
)
I do AJAX saving in my plugin Components Extended (see my signature below), you can look at the code for inspiration, see this excerpt for example:
PHP Code:
$global $USR;
if (requestIsAjax()) {
// protect against CSRF, basic check
if (!isset($USR) || $USR != get_cookie('GS_ADMIN_USERNAME'))
die();
// only continue if the request comes from the same domain & nonces match
if (empty($_GET['nonce']) || !check_nonce($_GET['nonce'], 'components_ext_action', 'components_ext.php'))
die();
}
Thank you ever so for the response. I am going to use the plugin for storing/keeping track of responses from the form. For the ajax post where should I be point the url to?