Forums

Stop processing a form

nfg 07 Feb, 2008
Hello,

I've been using Chrono Forms to chain together a bunch of different forms and it's a real timesaver. I particularly like the onSubmit fields where I can easily manage all kinds of things while forms are being processed.

One thing I really would like to do though is stop a form from being written to the database and stop the email from being sent if my user doesn't meet certain criteria.

For example, if I reload the final page displayed by Chrono Forms it will submit the data again, send and email again, and in fact, again and again and again if I keep hitting reload.

For reasons best known to myself I can't just redirect my page. I need the data stored in $_POST for my onSubmit code.

Is there some function or method I can call which will stop Chrono Forms from proceeding if I don't want it to?
GreyHead 07 Feb, 2008
Hi nfg,

I don't know. In extremis you can always test and hit die() in the OnSubmitBefore box. More practically, it would be easy to add test and then skip to the end of the page . . . I'm not quite sure what would work best for you.

Bob
nfg 07 Feb, 2008
Basically what happens is that they click on a link and get a coupon that's generated by GD. The coupon's in a new window for various reasons, so the other page still exists. The GD piece is outside of Joomla so I can't redirect from there.

Maybe I have to write a bot with an IFrame or something.

Going die() like that results in a blank page containing only the argument you supplied. Besides it breaks out of Joomla. It kills not just one application but everything that joomla happens to be doing at the time.

Anyway, I was hoping against hope for a chrono::stop_that() sort of thing.

Love the component by the way.

I'm getting a license, and I plan to review you well at the Joomla extensions site.

I'm really happy I found this.
GreyHead 07 Feb, 2008
Hi nfg,

Please say a bit more about what you are doing here. Do some users complete the form and others divert off to the coupon?

We could construct a ChronoStop but where would you call it from? If you return control to ChronoForms then it would be fairly easy to either continue the form processing OR redirect to your coupon page.

Basically I haven't yet understood the workfow here.

Bob
nfg 07 Feb, 2008
Sure I'll explain it a little.

Users get a coupon every time they fill out a survey. They can only fill out the survey every two weeks, and they can only do it three times.

User logs in and fills out the form.
The form redirects to another form where the user chooses a coupon.
Once they click submit they are taken to the form's exit page.
Here, because this is the payoff for them I need to control it so I test.
The user has filled out the form.
The user has not filled the form out more than 2 times
The user has not already downloaded their coupon
The user has not downloaded a coupon more than 2 times

Now.

I can prevent the user from downloading, and I can prevent them from seeing and filling out the forms based on the conditions.

Here on the exit page though, what I can't do is stop the email from being sent if the user reloads and resends the data, and I can't stop it from being written to the db.

It seems I may just have to redirect off the exit page and forget about $_POST. All the data is in the db anyway and I can track it using the userid. I'm doing that to some extent anyway.
nfg 08 Feb, 2008
OK I feel stupid.
I feel like a guy in a small room with a big stone it. I'm looking for a rock, but I can't find one.

The way to do this is:

In the onSubmit field (before the email is sent)
<?php
     if ( $conditions != true ) {
         mosredirect($url);
     }
?>
Duh!<br><br>Post edited by: GreyHead, at: 2008/02/09 20:31
This topic is locked and no more replies can be posted.