Posts: 143
Threads: 19
Joined: Dec 2010
Reputation:
5
I just noticed that when using the API to process forms via the POST method, the submissions in the database are skipping IDs. Is this because someone begins to fill out the form (creating a session), but then never clicks Submit?
Or is it because they are getting an error when they click submit? I'm a bit confused as to why some submission IDs are being skipped.
Somewhat related: the bit of code Ben always tells us to use in order to see error output I have found invaluable! But when that code outputs an error, can we have the output "DO" something?
1) On error output display, also display a custom message (for customers) letting them know there was a problem and that they should contact us.
2) Collect the error output and put it an email. The email would obviously go the FT install account admin (but this could also be customizable, I guess).
This would help in deciphering whether someone across the country (or in another country) is getting an error, what that error might be and then lets the admin know, so it can be addressed.
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hey guys,
Quote:I just noticed that when using the API to process forms via the POST method, the submissions in the database are skipping IDs. Is this because someone begins to fill out the form (creating a session), but then never clicks Submit?
Exactly! Whenever anyone goes to your form, a unique ID is assigned to them right away. So even if they don't submit the form, that submission ID will never get used again. The skipped IDs are totally normal and aren't any cause for concern.
michat - the bit of code you mentioned, is that the $g_default_error_reporting setting?
You *can* customize the displaying and gathering of those errors through PHP, I believe, but it's kind of fussy. Instead, PHP usually logs that info automatically in its own error logs. For problems of this nature, searching the error logs is a much more elegant way to handle them. I often look through my own logs to find out the sort of problems that are occurring that I didn't know about. Maybe contact your hosting provider to find out where they're stored.
Good luck!
- Ben
Posts: 143
Threads: 19
Joined: Dec 2010
Reputation:
5
(Dec 17th, 2011, 1:10 PM)Ben Wrote: michat - the bit of code you mentioned, is that the $g_default_error_reporting setting?
Indeed, very handy!
(Dec 17th, 2011, 1:10 PM)Ben Wrote: You *can* customize the displaying and gathering of those errors through PHP, I believe, but it's kind of fussy. Instead, PHP usually logs that info automatically in its own error logs. For problems of this nature, searching the error logs is a much more elegant way to handle them. I often look through my own logs to find out the sort of problems that are occurring that I didn't know about. Maybe contact your hosting provider to find out where they're stored.
I briefly glanced at the error logs in cPanel, but didn't see any kind of PHP logs, I'll have to call them next week about that.
With the idea that PHP error logs exist on the server, I'm not so concerned about the error output doing anything special now. However, I WOULD like to have a message display on error output for customers. Something like, "Oops, we've encountered an error while processing your form, please contact us to finish your request." Or something. Something in text, standardized, that I can customize.
Would that be as easy as adding an echo script somewhere?
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Dec 17th, 2011, 5:41 PM
(This post was last modified: Dec 17th, 2011, 5:42 PM by Ben.)
Quote:However, I WOULD like to have a message display on error output for customers. Something like, "Oops, we've encountered an error while processing your form, please contact us to finish your request." Or something. Something in text, standardized, that I can customize.
I'm not sure about that. What kind of errors are you trying to catch? Actual major errors like the submission not being able to be added? With POST/Direct forms, your options are pretty limited.
But with the API, you can set the following setting to false in your global/config.php:
The API debugging is on by default, so whenever a problem occurs (like invalid form IDs being passed to the API functions), it displays the Form Tools error page with the appropriate error code for you to look up (see: http://docs.formtools.org/api/index.php?...rror_codes). When you set that variable to false, each function will *return* the errors instead of redirecting to the error pages. So for example, instead of calling:
PHP Code: ft_api_process_form($params);
You would call:
PHP Code: list($success, $error_code) = ft_api_process_form($params);
It would behave in exactly the same way except when there was an error. In those cases, it would return false for $success, and the Form Tools API error code. You could do whatever you wanted with that info.
I *think* I standardized the return values for most the API functions, but you should probably test it out and tinker with the code.
Hope this helps!
- Ben
|