The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/showthread.php 26 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/showthread.php 26 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/showthread.php 26 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/showthread.php 137 forum_permissions
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1380 fetch_forum_permissions
/inc/functions.php 2909 forum_permissions
/showthread.php 621 build_forum_jump
Warning [2] Undefined array key "mybb" - Line: 1952 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1952 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 629 mark_thread_read
Warning [2] Undefined property: MyLanguage::$ratings_update_error - Line: 5 - File: showthread.php(732) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions_user.php 844 is_member
/inc/functions_post.php 406 purgespammer_show
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 1070 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1506 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 30 - File: showthread.php(1533) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 79 errorHandler->error
/showthread.php 1533 eval



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
Keeping values in fields with ft_api_check_submission_is_unique
#1
I've been working to combine validation along with ft_api_check_submission_is_unique and while it all works -- the values no longer stay in the fields on an error submission. If you remove the ft_api_check_submission_is_unique portion, it works fine.

EDIT: I had to adjust the live example link...
Here's the live example: http://fasports.com/az/phx/tournaments/t...r_TEST.php

And here's the code...

PHP Code:
    require_once("[PATH TO]/global/api/api.php");
    
    if(
$ft_initialize == "yes") { $fields ft_api_init_form_page($ft_id"initialize"); }
    else { 
$fields ft_api_init_form_page($ft_id); }
    
    
// $fields = ft_api_init_form_page($ft_id); // placeholder as it's defined above

    
$already_exists "";
    
    
// validation time!
    
$errors = array();
    if (isset(
$_POST['submit']))
    {
      
$rules = array();

      
$rules[] = "required,Team_Name,Please enter your team name.";
      
$rules[] = "required,Email_Address,Please enter your email address.";
      
$rules[] = "required,Captains_First_Name,Please enter your captain's first name.";
      
$rules[] = "required,Captains_Last_Name,Please enter your captain's last name.";
      
$rules[] = "required,Phone_Number,Please enter your phone number.";
      
$rules[] = "required,Terms_and_Conditions,Please confirm you have read and agree to the terms and conditions.";
      
      
$errors validate_fields($_POST$rules);
     
      
// no errors - great! Now we process the page. The ft_api_process_form does
      // the job of both updating the database and redirecting to the next page
      
if (empty($errors))
      {
        
$params = array(
          
"submit_button" => "submit",
          
"next_page" => "reg_confirm_new.php",
          
"form_data" => $_POST,
          
"finalize" => true
        
);        

    
    
 
$criteria = array(
  
"col_2" => $_POST["Team_Name"]
);
if (!
ft_api_check_submission_is_unique($ft_id$criteria$fields["form_tools_submission_id"]))
{    
  
// uh-oh! A submission already exists with this email address! Abort, abort! 
  // here, you could do something like set a variable like: $already_exists = true
  // and in the webpage do a little test to see if it's set. If so, let the user know 
  // what's going on
  
  
$already_exists true;
  
}
else
{
  
// call ft_api_process_form function here to continue processing the form submission
    
ft_api_process_form($params);
  
  
}  } } } 

And the code for the same thing but without the ft_api_check_submission_is_unique:

PHP Code:
    require_once("[PATH TO]/manager/registration/global/api/api.php");
    
    if(
$ft_initialize == "yes") { $fields ft_api_init_form_page($ft_id"initialize"); }
    else { 
$fields ft_api_init_form_page($ft_id); }
    
    
// $fields = ft_api_init_form_page($ft_id); // placeholder as it's defined above

    
$already_exists "";
    
    
// validation time!
    
$errors = array();
    if (isset(
$_POST['submit']))
    {
      
$rules = array();

      
$rules[] = "required,Team_Name,Please enter your team name.";
      
$rules[] = "required,Email_Address,Please enter your email address.";
      
$rules[] = "required,Captains_First_Name,Please enter your captain's first name.";
      
$rules[] = "required,Captains_Last_Name,Please enter your captain's last name.";
      
$rules[] = "required,Phone_Number,Please enter your phone number.";
      
$rules[] = "required,Terms_and_Conditions,Please confirm you have read and agree to the terms and conditions.";
      
      
$errors validate_fields($_POST$rules);
     
      
// no errors - great! Now we process the page. The ft_api_process_form does
      // the job of both updating the database and redirecting to the next page
      
if (empty($errors))
      {
        
$params = array(
          
"submit_button" => "submit",
          
"next_page" => "reg_confirm_new.php",
          
"form_data" => $_POST,
          
"finalize" => true
        
);
        
        
ft_api_process_form($params);
        
        
$fields array_merge($fields$_SESSION["form_tools_form"]);
    }
    else
    
$fields array_merge($fields$_POST);         
        
      } 

I'm assuming there's some portion of code missing that's not relaying the values in an errored submission... but I just have no idea what that might be.

Thanks!
Reply
#2
I adjusted the code a little and I think I made a little progress... by adding in the following two snippets:

PHP Code:
        $fields array_merge($fields$_SESSION["form_tools_form"]); 

PHP Code:
      $fields array_merge($fields$_POST); 

Into the code as shown here:

PHP Code:
      // no errors - great! Now we process the page. The ft_api_process_form does
      // the job of both updating the database and redirecting to the next page
      
if (empty($errors))
      {
        
$params = array(
          
"submit_button" => "submit",
          
"next_page" => "reg_confirm_new.php",
          
"form_data" => $_POST,
          
"finalize" => true
        
);        
    
    
     
$criteria = array(
      
"col_2" => $_POST["Team_Name"]
    );
    if (!
ft_api_check_submission_is_unique($ft_id$criteria$fields["form_tools_submission_id"]))
    {    
      
// uh-oh! A submission already exists with this email address! Abort, abort! 
      // here, you could do something like set a variable like: $already_exists = true
      // and in the webpage do a little test to see if it's set. If so, let the user know 
      // what's going on
      
      
$already_exists true;
      
$fields array_merge($fields$_POST); 
      
    }
    else
    {
      
// call ft_api_process_form function here to continue processing the form submission
        
ft_api_process_form($params);
        
$fields array_merge($fields$_SESSION["form_tools_form"]);
  
}  } } } 

Now when running tests, if you error during validation, the fields don't maintain their values -- but if you only error on the name's uniqueness, they do keep their values.
Reply
#3
Hey msaz,

Sorry for not replying sooner - I've had a pretty busy week! Would you mind posting your entire code? I'd like to see the whole shebang to see if I can spot anything out of whack.

Thanks!

- Ben
Reply
#4
(Oct 29th, 2009, 7:54 PM)Ben Wrote: Hey msaz,

Sorry for not replying sooner - I've had a pretty busy week! Would you mind posting your entire code? I'd like to see the whole shebang to see if I can spot anything out of whack.

Thanks!

- Ben

Sure thing -- thanks so much for helping me.

Attached below are the two files involved (I think, its been a little while since I was working on this, so if it seems like anything is missing just let me know...)

Both are included into other pages which define whether the form needs to be initialized and what ID it is... but everything else should be there. The reg_api.php file contains versions of both the working code w/out the ft_api_check_submission_is_unique and the version not working with it (one is listed as "league registration" and the other "tournament registration").

And on the confirm page, of course, is the:

PHP Code:
require_once("[PATH TO]/global/api/api.php");
$fields ft_api_init_form_page();
ft_api_clear_form_sessions(); 

That should be all of it..

Thanks again!


.php   tournament_registration_new.php (Size: 7.25 KB / Downloads: 7)
.php   reg_api.php (Size: 3.7 KB / Downloads: 6)
Reply
#5
I did experience this type of issue also.... I changed this:

$errors = validate_fields($_POST, $rules);

// no errors - great! Now we process the page. The ft_api_process_form does
// the job of both updating the database and redirecting to the next page
if (empty($errors))
{
$fields = ft_api_init_form_page(1);
$params = array(
"submit_button" => "continue",
"next_page" => "step2.php",
"form_data" => $_POST,
"file_data" => $_FILES
);

$criteria = array(
"attendee_last_name" => $_POST["attendee_last_name"],
"attendee_zip" => $_POST["attendee_zip"],
"attendee_email" => $_POST["attendee_email"],
"is_finalized" => "yes",
"status" => "Active"
);

if (!ft_api_check_submission_is_unique(1, $criteria, $files["form_tools_submission_id"]))
{
$already_exists = true;
}
else
{
ft_api_process_form($params);
}
}
}

?>


to this:

$errors = validate_fields($_POST, $rules);

}

if (empty($errors))
{
$fields = ft_api_init_form_page(1);
$params = array(
"submit_button" => "continue",
"next_page" => "step2.php",
"form_data" => $_POST,
"file_data" => $_FILES
);

$criteria = array(
"attendee_last_name" => $_POST["attendee_last_name"],
"attendee_zip" => $_POST["attendee_zip"],
"attendee_email" => $_POST["attendee_email"],
"is_finalized" => "yes",
"status" => "Active"
);

if (!ft_api_check_submission_is_unique(1, $criteria, $files["form_tools_submission_id"]))
{
$already_exists = true;
}
else
{
ft_api_process_form($params);
}
}


?>

and the problem was resolved!!!
Reply
#6
Can you point out exactly what you did differently? Or post more of the code? I'm trying to compare your examples and the only thing I can identify is an orphan end bracket underneath where you declare the $errors variable.

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)