HOWTO: How to include forms that accept user input, not just the Feedback form

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
Foxy

HOWTO: How to include forms that accept user input, not just the Feedback form

Post by Foxy »

Hello,

Does anyone know how to include in CMS Pages forms that accept user input and when the user clicks the submit button to process that form and display the results in the page.

As far as I realised displaying a form is not a problem but how I integrate it with CMS Made Simple frame work.

Thank you!
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: HOWTO: How to include forms that accept user input, not just the Feedback fo

Post by megabob3 »

Foxy wrote: Hello,

Does anyone know how to include in CMS Pages forms that accept user input and when the user clicks the submit button to process that form and display the results in the page.

As far as I realised displaying a form is not a problem but how I integrate it with CMS Made Simple frame work.

Thank you!
To do that you need some knowledge on programming.
Right because the input must processed!!!

You have to create or a simple plugin TAG or a module.
So you need to know a bit of PHP.


Bye ;)
Foxy

Re: HOWTO: How to include forms that accept user input, not just the Feedback form

Post by Foxy »

Thx for your quick reply!

Well I know PHP but I am new to CMS in general and CMS Made simple in particular.

I need a prety quick solution so I do not have the time to write a module. So custom tags might work for me.

But I did not figure it out what hidden parameters the form should have to make sure I get back in the right page, template and so on.

So the form must get me into a code that will process the input and from then I must redirect to a page that would display something usefult but making use of the templates.

So any guide lines on how to integrate the form processing with the CMS Made Simple or some link where I could read some documentation about the CMS Made Simple framework.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: HOWTO: How to include forms that accept user input, not just the Feedback fo

Post by Ted »

The absolute easiest way to handle it is...

1. Make 2 pages in cmsms.  One will be the form.  One will be for the results.  You'll probably want to set the 2nd page to not show in the menu.
2. On the form page, just make an html form as normal.  It's probably best to make a "namespace" of sorts for your parameters so that they don't get any conflicts with the internal CMSMS stuff.  And also, make sure the action points to your second page.

Code: Select all

<form action="processpage.shtml" method="post">
<input type="text" name="myform_name" />
<input type="text" name="myform_address1" />
</form>
etc.
3. Make a user defined tag.  Call it process_form or something along those lines.  In it, do something like:

Code: Select all

$name = '';
if (isset($_POST['myform_name']))
{
    $name = $_POST['myform_name'];
}
$address = '';
if (isset($_POST['myform_address']))
{
    $address = $_POST['myform_address'];
}

//Do something with this data here...
4. Put the {process_form} tag in your second page.
5. Done (hopefully!)

Obviously, that's as simplistic as possible, but you should get the idea.
Foxy

Re: HOWTO: How to include forms that accept user input, not just the Feedback form

Post by Foxy »

It's that simple  ;D

I stat to feel bad about my self  ::)

I thought that the form's action parameter must be something realy complicated like the one generated by "Feedback Form" and I was troubled because I did now know where to get those parameters.

Well... then I'll try just with the name of my page... hope it works....


Thanks!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: HOWTO: How to include forms that accept user input, not just the Feedback form

Post by Ted »

Yeah, the URLs are only complicated when the module API generates them.  For the handcoded stuff, we try to keep it as simple as possible.  :)
Foxy

Re: HOWTO: How to include forms that accept user input, not just the Feedback form

Post by Foxy »

Yeah it Works!

For those that may be interested in this the action path was something like:

"?page=process_form"

where "process_form" is the alias of the page that calls that custom tag.

Many thx to all of you! It wat that simple!  ;D
Post Reply

Return to “Tips and Tricks”