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
/printthread.php 16 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
/printthread.php 16 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
/printthread.php 16 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
/printthread.php 16 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
/printthread.php 16 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
/printthread.php 16 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
/printthread.php 76 forum_permissions
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(257) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/printthread.php(257) : eval()'d code 2 errorHandler->error
/printthread.php 257 eval
/printthread.php 117 printthread_multipage
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
SQL error when using ft_api_check_submission_is_unique - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: SQL error when using ft_api_check_submission_is_unique (/showthread.php?tid=264)

Pages: 1 2


RE: SQL error when using ft_api_check_submission_is_unique - msaz87 - Sep 5th, 2009

Hey Ben,

I updated the API files and also my code, which now looks like this, in full:

PHP Code:
<?php
require_once("../[path to FT]/global/api/api.php");
$fields ft_api_init_form_page(28);

$already_exists "";

// validation time!
$errors = array();
if (isset(
$_POST['submit']))
{
  
$rules = array();
  
$rules[] = "required,how_they_heard_about_us,Please select a referral source.";
  
$rules[] = "required,email,Please enter your email address.";
  
$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" => "thanks.php",
      
"form_data" => $_POST,
      
"finalize" => true
    
);
    
    
$criteria = array(
  
"col_1" => $_POST["email"]
);
if (
ft_api_check_submission_is_unique(28$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);
  
  
}





  }
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>


<head>
</head>
<body>

<? if($already_exists == true) { echo("**This email already exists**<br/><br/>"); } ?>

<?php
// if $errors is not empty, the form must have failed one or more validation 
// tests. Loop through each and display them on the page for the user
if (!empty($errors))
{
  echo 
"<div class='error'>Please fix the following errors:\n<ul>";
  foreach (
$errors as $error)
    echo 
"<li>$error</li>\n";
 
  echo 
"</ul></div>"
}
?>


Join our mailing list for league and tournament updates:
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">

    <input type="text" name="email" size="30">
    <select name="how_they_heard_about_us">
        <option value="">Your Referral Source</option>
        <option value="MySpace">MySpace</option>
        <option value="Facebook">Facebook</option>
        <option value="Search Engine">Search Engine</option>
        <option value="Friend">Friend</option>
        <option value="Advertisement">Advertisement</option>
        <option value="Other">Other</option>
    </select>&nbsp;
    <input type="submit" name="submit" value="submit">

</form>

</body>
</html> 

But I still get the same problem regarding it always coming back telling me the submission isn't unique.

Did I do something wrong?

Thanks so much for your help with this, Ben!


RE: SQL error when using ft_api_check_submission_is_unique - azparrothead - Sep 6th, 2009

I also updated to the new version of thr API and same result in a simple test....not unique message when it is.


RE: SQL error when using ft_api_check_submission_is_unique - Ben - Sep 6th, 2009

Hey azparrothead,

Hmm! Would it be possible for you to send me your PHP page? I'd like to test it out myself (ben.keen@gmail.com).

Thanks!

- Ben


RE: SQL error when using ft_api_check_submission_is_unique - msaz87 - Sep 27th, 2009

Just to recap on this thread the solution for anyone else who might run into the problem... via Ben and azparrothead...

The code line involving the IF needs the addition of a "!" before the ft_api_check_submission_is_unique:
PHP Code:
if (!ft_api_check_submission_is_unique(1$criteria$files["form_tools_submission_id"]))
{
$already_exists true;
}
else
{
ft_api_process_form($params);