How to put form's results on custom page
Permalink 1 user found helpful
Hello, I can't find a way to get data from simple form which goes with core. I made a form, filled it and now the only place I can see it is dashboard. But I actually need to put this data on one of my pages (this is something like participants list). How can I do this, please? Tried to use Simple PHP block but seems it work only with fairily simple php code. I tried to insert code from this file 'concrete/single_pages/dashboard/reports/forms.php' into it and got a lot of errors. It turned then that it didn't like opening php-tags (<?php). I deleted then some of these tags (except those in html tags) and got an almost empty page with h1 "Form results" and below I saw listing of this file.
Now I'm totally lost because I'm unable to buy add-ons from marketplace, not saying it is not the right way to buy an add-on while I'm sure there should be a simple solution...
Now I'm totally lost because I'm unable to buy add-ons from marketplace, not saying it is not the right way to buy an add-on while I'm sure there should be a simple solution...
Anyone please?...
jgarcia: thank you, did you ever read my post?...this is exactly what I don't have an opportunity to do: $55, heh...
I wish I could buy this and some other add-ons, like forums...
Unfortunately, many quite simple and hardly needed add-ons are not free. And this make one take a thought about using other CMS-s, maybe not as good as Concrete but offering to users much more free popular add-ons.
I wish I could buy this and some other add-ons, like forums...
Unfortunately, many quite simple and hardly needed add-ons are not free. And this make one take a thought about using other CMS-s, maybe not as good as Concrete but offering to users much more free popular add-ons.
This is what I've been trying to accept. All developers have the right to order pizza and beer for their exceptional work. I've already expressed many times here that I want free beer and others may too. I guess this makes two of us. The only options are:
1. Pay for add-ons
2. Learn programming and C5 API and do it yourself
3. Use another CMS
and it all comes down to whichever is the most favorable for you. I've tried about 10 different CMSc and they're all more or less similar... that is cr*p if you want to change anything without spending a year figuring out how they work. If you just need default functionality like a blog, default search, default themes etc. you'll find all of them will do the job. But when it comes to security, ease of use (for both developers and users) - C5 is light years better than anything else.
So, the only thing I can do is to learn C5 API, post my blocks for free and encourage others to do the same
Like free beer? BYO and share! :)
1. Pay for add-ons
2. Learn programming and C5 API and do it yourself
3. Use another CMS
and it all comes down to whichever is the most favorable for you. I've tried about 10 different CMSc and they're all more or less similar... that is cr*p if you want to change anything without spending a year figuring out how they work. If you just need default functionality like a blog, default search, default themes etc. you'll find all of them will do the job. But when it comes to security, ease of use (for both developers and users) - C5 is light years better than anything else.
So, the only thing I can do is to learn C5 API, post my blocks for free and encourage others to do the same
Like free beer? BYO and share! :)
If you know PHP and C5 API it's very easy to do. Just override the 'external_form' block and change it to whatever you want, then your form's PHP/HTML/JS are only limited by your skills and imagination this way. Have a look at my Contact Form example (http://www.concrete5.org/community/forums/block_requests/contact-form-email#60262/) where I wrote everything myself from scratch, this should give you an idea.
What form are you using? If you need Search, have a look at this example (http://www.concrete5.org/community/forums/block_requests/custom-attribute-search-block#62083/) - I did exactly the same thing, I override the existing search form (plus a few more files) but I added much more functionality to suit my purpose.
What form are you using? If you need Search, have a look at this example (http://www.concrete5.org/community/forums/block_requests/custom-attribute-search-block#62083/) - I did exactly the same thing, I override the existing search form (plus a few more files) but I added much more functionality to suit my purpose.
Thank you very much! I will surely try this!
Last time I tried to paste php into Simple php block and it didn't work (it was wrong approach I guess now).
Then I decided to go another way: I looked at the guestbook which is in core and I can see data entered from dashboard, so I thought I could pull data from it somehow.
Actually I don't know PHP and C5 API, just html a bit, but I'd love to know it.
One question: your example is a mail form and if I understood right data is gathered through the form and then it is sent right away. I mean data is not written into db. But how can I pull data which is already in db (this way works form which is in core)?
Last time I tried to paste php into Simple php block and it didn't work (it was wrong approach I guess now).
Then I decided to go another way: I looked at the guestbook which is in core and I can see data entered from dashboard, so I thought I could pull data from it somehow.
Actually I don't know PHP and C5 API, just html a bit, but I'd love to know it.
One question: your example is a mail form and if I understood right data is gathered through the form and then it is sent right away. I mean data is not written into db. But how can I pull data which is already in db (this way works form which is in core)?
I'd say the PHP block is good for pure PHP code because (correct me if I'm wrong) you should not use <?php ?> tags in there but as soon as you mix PHP and HTML you have to separate them with the tags which either get deleted during the block parsing or are ignored nd then the code doesn't work of course. So the best way to make forms is to use the external_form block and override it.
I know PHP but I barely know C5 API. Please have read the help section here, it really helped me to get started, to start understanding the way C5 works. But in a few words it's this:
C5 is built with blocks, packages and other modules (jobs, models, controllers etc.) which are all in the /concrete folder. The most clever thing C5 does is that by default it uses all code from the /concrete folder. But before using it, it checks first if the same block, controller, jobs is available in the root folder - this is where you can extend and change the existing blocks and all. If you simply copy a whole folder (block), say 'external_form' from /concrete/blocks and paste it into /blocks, then if you add that block to your site, C5 will use the /block/external_form rather than /concrete/blocks/external_form. The idea is very simple - copy and paste any default block and change it as you want without breaking the core blocks/functionality. Of course you can edit the core /concrete file, but then if you upgrade C5 later you will loose all that you've done and you have to start from scratch. If you override the core functionality, this way all you need to do during the upgrade is to replace the root folders (/blocks, /libraries, /themes etc.) without touching the system folders.
Not sure if I explain it right but hope you get the idea.
Then, the blocks's main files are view.php - this is the main HTML form if you like which can also have PHP code in it, and controller.php - this is the main PHP form processor. And this is how presentation is separated from processing. There are other files in each block, but to get started all you need to do is
1. copy & paste external_form folder from /concrete/blocks into /blocks
2. change the /external_form/forms/test_form.php to design your own form
3. change the /external_form/forms/controllers/test_form.php to do whatever you want with your own form
So, have a look at my 2 blocks. I also override a few other modules to process my form. But the ideas is the same. And read the Help sections. As I said, they're not going to help you do everything you want, but it's a good start.
As to my forms, the contact form gets all the data from the input fields (name, email etc.) and sends it all to my email address after passing all the security checks. It doesn't use the database because I don't store anything in the for this form. The customised search form is a package, not a block, you can actually install it through the dashboard, and it again takes the user selected inputs (from the comboboxes) and searches my website using the database (because all the content is stored in the DB).
So, what are you trying to do? What form do you need? Contact, Search, FAQ...? BTW, you can override the /concrete/blocks/form form which I believe stores data in the database as well as the sent email. But it didn't suit my needs, so I've done mine from scratch and the external_form is the best to start with.
Clear as mud? :)
I know PHP but I barely know C5 API. Please have read the help section here, it really helped me to get started, to start understanding the way C5 works. But in a few words it's this:
C5 is built with blocks, packages and other modules (jobs, models, controllers etc.) which are all in the /concrete folder. The most clever thing C5 does is that by default it uses all code from the /concrete folder. But before using it, it checks first if the same block, controller, jobs is available in the root folder - this is where you can extend and change the existing blocks and all. If you simply copy a whole folder (block), say 'external_form' from /concrete/blocks and paste it into /blocks, then if you add that block to your site, C5 will use the /block/external_form rather than /concrete/blocks/external_form. The idea is very simple - copy and paste any default block and change it as you want without breaking the core blocks/functionality. Of course you can edit the core /concrete file, but then if you upgrade C5 later you will loose all that you've done and you have to start from scratch. If you override the core functionality, this way all you need to do during the upgrade is to replace the root folders (/blocks, /libraries, /themes etc.) without touching the system folders.
Not sure if I explain it right but hope you get the idea.
Then, the blocks's main files are view.php - this is the main HTML form if you like which can also have PHP code in it, and controller.php - this is the main PHP form processor. And this is how presentation is separated from processing. There are other files in each block, but to get started all you need to do is
1. copy & paste external_form folder from /concrete/blocks into /blocks
2. change the /external_form/forms/test_form.php to design your own form
3. change the /external_form/forms/controllers/test_form.php to do whatever you want with your own form
So, have a look at my 2 blocks. I also override a few other modules to process my form. But the ideas is the same. And read the Help sections. As I said, they're not going to help you do everything you want, but it's a good start.
As to my forms, the contact form gets all the data from the input fields (name, email etc.) and sends it all to my email address after passing all the security checks. It doesn't use the database because I don't store anything in the for this form. The customised search form is a package, not a block, you can actually install it through the dashboard, and it again takes the user selected inputs (from the comboboxes) and searches my website using the database (because all the content is stored in the DB).
So, what are you trying to do? What form do you need? Contact, Search, FAQ...? BTW, you can override the /concrete/blocks/form form which I believe stores data in the database as well as the sent email. But it didn't suit my needs, so I've done mine from scratch and the external_form is the best to start with.
Clear as mud? :)
Thank you very much, your answer is very clear.
My site is far from commerce, it's rather social. Sometimes very interesting people like alternative energy inventors and such are getting in touch with me and I organize meetings with them, broadcast, video etc.
There is a big interest here in such meetings and many people would like to attend meetings and talk to these inventors themselves.
What I try to do is a form where people who want to participate in such meetings could register themselves and get all records from this form on their screen. While I'm not an organization, just a private person, I can invite only a limited number of people. This is why I need this form so people could see how many free "sits" or places are left.
I'm going to try your suggestions and would use your helpfull post.
My site is far from commerce, it's rather social. Sometimes very interesting people like alternative energy inventors and such are getting in touch with me and I organize meetings with them, broadcast, video etc.
There is a big interest here in such meetings and many people would like to attend meetings and talk to these inventors themselves.
What I try to do is a form where people who want to participate in such meetings could register themselves and get all records from this form on their screen. While I'm not an organization, just a private person, I can invite only a limited number of people. This is why I need this form so people could see how many free "sits" or places are left.
I'm going to try your suggestions and would use your helpfull post.
So, if I understand it right, you want to have a record of how many seats have been taken and how many are still left? Without thinking too much, I think the simplest solution is to have a counter in a database which will be decremented when a person registers. All you need to do is to store a numeric value in a database which will change on successful registration. You can also show this number to the user before registration to let them know how many seats are still left.
If you also want to store the registered users details, then you need a few more values to store. And you don't need to know C5 API for that. Just make a simple email registration form with that database. If you want only your CMS users to be able to register and do other things, then you need to know C5 API, in particular how to get/check CMS users (read help for that). And your code will be a bit more involved.
But as far as the form itself is concerned, you can get my contact form, change it to suit your needs and just add a small code to change the remaining seats number in the database on successful form submission.
In my contact form controller towards the end of file, add your database code there (it will only execute if the form submission is successful):
and instead of or in addition to sending the email, you can get all those values from the submitted form into your database.
To make and use a MySQL database you can either write your own code, or you can use C5 API whichever is easier. And there's so many tutorials on the internet how to use MySQL with PHP.
If you also want to store the registered users details, then you need a few more values to store. And you don't need to know C5 API for that. Just make a simple email registration form with that database. If you want only your CMS users to be able to register and do other things, then you need to know C5 API, in particular how to get/check CMS users (read help for that). And your code will be a bit more involved.
But as far as the form itself is concerned, you can get my contact form, change it to suit your needs and just add a small code to change the remaining seats number in the database on successful form submission.
In my contact form controller towards the end of file, add your database code there (it will only execute if the form submission is successful):
if (!$e->has()) { Loader::library('3rdparty/Zend/Mail'); $zm = new Zend_Mail(APP_CHARSET); $zm->setSubject($subject); $zm->setBodyText($txt_message); $zm->setBodyHtml($html_message); $zm->addTo($to); $zm->setFrom($email); $zm->send(); $_SESSION['stamp'] = time(); $this->set('no_error_msg', $no_error_msg); // <= ADD YOUR CODE HERE return true; } else { $errors = $e->getList();
Viewing 15 lines of 18 lines. View entire code block.
and instead of or in addition to sending the email, you can get all those values from the submitted form into your database.
To make and use a MySQL database you can either write your own code, or you can use C5 API whichever is easier. And there's so many tutorials on the internet how to use MySQL with PHP.