Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

pre-mod: multi-part submit form

Quote Reply
pre-mod: multi-part submit form
Hi,

I've been playing around with a multi-part submission for as a method of helping to avoid being spammed and to make people stop and look a little harder before they continue with their site suggestion. I've got it working but have a few problems (probably of my own making Smile) and wondered if anyone could offer some insight as to how to overcome them.

Here's what I've done so far:

Created three templates; add_step_1.html > add_step_2.html > add_step_3.html

In each template I have changed the 'Submit' value; Step 1 - 'step2', Step 2 - 'step3' and Step 3 - 'add' (this is so that the add script knows which template to display next.)

I've copied add.cgi to addmulti.cgi and added some new code so that it looks in the form for the value of the 'submit' variable and goes forward to the next part if its not 'add' (the last thing to do!):

else {
$category = &get_category_list ();
}

if ($in->param('step2')) {
my $id = $in->param('ID');
my $sitetitle = $in->param('Title');
my $siteurl = $in->param('URL');
&site_html_add_form_2 ({ catid => $id, Title => $sitetitle, URL => $siteurl, Category => $category, banner_html => $banner_html, button_html => $button_html, text_html => $text_html, %in }, $dynamic);
}
elsif ($in->param('step3')) {
my $id = $in->param('ID');
my $sitetitle = $in->param('Title');
my $siteurl = $in->param('URL');
my $sitedescription = $in->param('Description');
&site_html_add_form_3 ({ catid => $id, Title => $sitetitle, URL => $siteurl, Description => $sitedescription, Category => $category, banner_html => $banner_html, button_html => $button_html, text_html => $text_html, %in }, $dynamic);
}
else {
&site_html_add_form_1 ({ catid => $id, Category => $category, banner_html => $banner_html, button_html => $button_html, text_html => $text_html, %in }, $dynamic);
}


You may notice that in each step the previous variables are passed to the template so that they can be 'forwarded' with each step of the submission (I found that if I didn't do that it would forget them and give an error at the point of adding the suggestion to the database. I've also got some extra tags for my banners and buttons, etc. - ignore those.)

In addition, the 'template' calls have been changed in HTML_Templates.pm so each one calls a different template.html file; 1, 2 & 3.

You can see it working (its not 'live' yet so please put 'Testing' or something obvious like that in the fields if you wish to try it out) at: http://www.qango.com/cgi-local/or/addmulti.cgi?ID=54

It works fine if you do a 'good' suggestion and stick to the guidelines and required fields, etc., and adds the suggestion to the validation database just as it does on the single part form, but I have got a few issues that I'm sure people will come across if they use it as it is.

1) Going-back to a previous part of the form (not really sure how to do it?)
2) Error checking the form fields at each 'step' rather than at the end?
3) Re-loading without the 'Re-post Form Data' request appearing?
4) Server complaining it can't find the form data after it's been left on-screen for a short time and failing to do anything other than sit at whatever step you are up to?

I may have gone about it completely the wrong way, if I have I wouldn't mind some pointers as to how I should re-work it, or start again Smile


All the best
Shaun

Quote Reply
Re: pre-mod: multi-part submit form In reply to
In Reply To:
1) Going-back to a previous part of the form (not really sure how to do it?)
Javascript.

In Reply To:
2) Error checking the form fields at each 'step' rather than at the end?
Add your own error codes like:

Code:

if ($in->param('something') eq "") {
$error .= qq|Something|;
}


Then add the following codes:

Code:

if ($error) {
chomp $error;
&site_html_add_step_failure ({error => $error}, $dynamic);
}


In Reply To:
3) Re-loading without the 'Re-post Form Data' request appearing?
Add additional query codes to query the VALIDATE and LINKS tables.

In Reply To:
4) Server complaining it can't find the form data after it's been left on-screen for a short time and failing to do anything other than sit at whatever step you are up to?
Browser issue really.


Regards,

Eliot Lee
Quote Reply
Re: pre-mod: multi-part submit form In reply to
Eliot,

Thanks, I've played around with it a bit more now and taken on-board your suggestion of 'error_add_step_x.html' - it's worked a treat Smile (in fact I've added more 'specific' error pages to cover other things as well).

I created a new error template for each step which includes all of the form data and pre-fills the fields that have so-far been submitted. This also means that there's no need to go 'back' (the fields were'nt available on the standard error template).

At each step it now checks to make sure something has been entered in each field, and if not it gives an error using a template based on the 'step' the user is at (including the fields for that step). I've also changed the variables so they're 'set' at the start instead of each step routine.

To get around the 're-load' problem I've simply added a link to the bottom of steps 2 & 3 that point back to addmulti.cgi with the category ID so someone can start again.

Well, I suppose the final test it to let my users have a go at using it - if anyone can break it they can Smile

All the best
Shaun

Quote Reply
Re: pre-mod: multi-part submit form In reply to
I would double check your "error" codes...I tried adding a site and the following are buggy:

1) Checking URL for correct format...I simply typed in a bunch of spaces and it allowed me to pass through.

2) Description...I don't know if you require this field or not, but I also was able to put a bunch of spaces without a problem.

3) When I did get to the error screen, none of the fields were filled in with inputted values.

BTW: There is a way of having a different splash page for the first "add" page that forces users to choose a category rather than using a static web page like you have in your site.

Wink

I have this working in my site where users have to choose a category first before adding a link via a drop-down menu that basically links to the add.cgi with the ID parameter of the CategoryID.

Regards,

Eliot Lee
Quote Reply
Re: pre-mod: multi-part submit form In reply to
Eliot,

1) I know I need to add back-in some of the validation details to the table itself, such as the url format checking, etc. but I'm not sure how I would check for a block of spaces?

2) Same again here, really - just need to check for spaces.

3) The fields that are filled-in are the ones in green that have been submitted in the previous step/s, but if you added spaces instead of text then they will probably have appeared blank :)

I'm not keen to offer a drop-down box for catgeories because I've got 7500+ and it'd be a hell of a list for people to go through, and take quite a while to load each time. I'm happy with having them select a category before they submit and passing the ID at the start.

It may be that over time I find it isn't as easy for people to use and go back to the single form, but I just wanted to challenge myself to do it and have quite enjoyed it Smile (although my tweaks are not always sucessfully!).

All the best
Shaun