FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New Error (Can't reproduce)
#1
Got a message from a client this morning that when trying to submit an online form, he got the following error. What does this mean? I can't seem to reproduce the error.

Code:
Notice: Undefined index: {field name was here} in
/{formtools root}/global/code/validation.php on line
114

Warning: Cannot modify header information - headers already sent by
(output started at
/{formtools root}/global/code/validation.php:114)
in /{formtools root}/global/api/api.php on line 881
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#2
Getting reports from more and more people encountering trouble, with no idea how to help them. I've checked the code over again and can't seem to find any problems... Will go through it all one last time tonight.

If it matters, I don't think any trouble started until I upgraded to 2.2.0.

B
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#3
So upon further investigation, it seems that the error had something to do with one or two specific form fields (that happen to be different checkboxes with exact same values).

Apparently, when the form processor was setup in FT admin, both checkboxes were given the same option list. I've since corrected this, so they each use a different option list now. Hopefully that corrects the problem. Here's what I mean:

Code:
<input name="good_sam_member" type="checkbox" value="yes" <?php if (@$fields["good_sam_member"] == "yes") echo "checked"; ?> />

Code:
<input name="escapees_member" type="checkbox" value="yes" <?php if (@$fields["escapees_member"] == "yes") echo "checked"; ?> />

Both fields only have one option - "yes" - and FT thought it would make sense for both fields to use the same option list, since the option values were identical.

Crossing my fingers that this solves the problem!
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#4
Well, after much hassle of going in and manually fixing the Field Options in FT Admin, it appears that was NOT the problem, after all. Still getting error messages from people submitting the external forms and I for some odd reason I can't even reproduce them. Something fishy going on. Not to be smart aleky, but I'm more and more certain this has something to do with 2.2.0, I'm just not sure what exactly.
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#5
New idea!

This may be related to my validation script.

Code:
$rules[] = "if:good_sam_member=yes,required,good_sam_number,Please enter your Good Sam MEMBERSHIP NUMBER.";
$rules[] = "if:escapees_member=yes,required,escapees_number,Please enter your Escapees MEMBERSHIP NUMBER.";

The fields good_sam_member and escapees_member are checkboxes (see my previous reply). Can you do an if statement like that? Or does the value have to be "checked" or something? It's happening now to almost all my checkboxes with only one option that have an if statement.

At least I've narrowed it down a little.
Update: I have reproduced the error message by NOT checking the checkboxes in question, then submitting the form.

This is definitely a validation issue. I changed the validation script to:
Code:
$rules[] = "if:good_sam_member!=,required,good_sam_number,Please enter your Good Sam MEMBERSHIP NUMBER.";
$rules[] = "if:escapees_member!=,required,escapees_number,Please enter your Escapees MEMBERSHIP NUMBER.";

But got the same error message. Actually, the error message references line 119, instead of 114, which is to be expected.

I'm guessing I simply can't use validation on a checkbox? Or at least, not this type of validation.

EDIT: And this seems odd, because I KNOW I had this validation in place while using the previous version of the core.
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#6
Hi michatmaster,

Sorry for not getting back to you sooner. Just playing catch-up now.

You *may* be right it's 2.2.0 related, but I can't see the cause just yet.

First off, do you have error reporting turned up high in your config.php file ($g_default_error_reporting = 2047)? If so, ANY minor warning (such as referencing a var that isn't defined - like a checkbox field that wasn't checked) will output a notice/warning in the code and prevent the API from redirecting the user to the next page.

If you have that var set, a quick fix would be to just comment it out.

Looking over the validation code, it actually looks like the problem lies there: I think it *will* throw a notice/warning when attempting to reference a key that doesn't exist in the $fields var (line 119).

Try this: change line 119 from this:

PHP Code:
else if ($comparison == "not_equal" && $fields[$field_to_check] == $value_to_check

To this:

PHP Code:
else if ($comparison == "not_equal" && (!array_key_exists($field_to_check$fields) || $fields[$field_to_check] == $value_to_check)) 

Let me know if that helps.

- Ben
Reply
#7
Well, after changing the validation.php code, I no longer get the error mentioned in my post. YAY!

However, using the following validation rule on a test form doesn't work. I can select the checkbox in question, but the requirement doesn't prevent the form from submitting.

Code:
$rules[] = "if:certificates=Other,required,other_certs_possessed, Please enter the type of CERTIFICATE.";

Link to test form thank you page: https://www.campmackinaw.com/secure/_test_clear.php
Link to test form: https://www.campmackinaw.com/secure/_test.php
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#8
Heya,

Hmm... interesting problem. This may be a bug, by the looks of it. Generally, the if: condition isn't used much on the server, just with the RSV client-side version of the validation, so this may be a bug that's slipped by.

Could you do a quick debug and add this on line 112:

PHP Code:
if ($field_to_check == "certificates")
{
  
print_r($fields[$field_to_check]);
  exit;


Then put through a submission again, with the Certificates checkbox checked. My hunch is that it'll output an array - in which case it's a bug.

Let me know!

- Ben



Reply
#9
I got the following output:

Code:
Array ( [0] => Other )
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply
#10
Creating a new thread for post that was here as I just figured out the problem and it's entirely a different issue.
Not a FT employee, just a FT user lending a hand. If I've been helpful, please rate.

[Image: giraffe_long_85.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)