The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 871 - File: showthread.php PHP 7.4.15 (Linux)
File Line Function
/showthread.php 871 errorHandler->error


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
Manually appending new fields to a form using PHP
Hi, Ben.

Really quick question:

I have migrated across from 1.5 > 2.05 and am finishing off updating a substantial chunk of my prior PayPal integration scripts. Naturally, I thought I'd make some improvements along the way but I need some clarification as on how to proceed or if I'm missing anything in particular.

IPN processor works; I've written further code to automate database entries upon verification but I need some help. The following chunk of code checks to see if any of the dedicated paypal fields I've declared are present in the corresponding form table; if not, create them:

PHP Code:
// PayPal IPN Verified

//some code

// boom! check if paypal fields exist in table
$query = ("SELECT mc_gross,mc_fee ".
"FROM ".$g_table_prefix."form_".$form_id." ".
"WHERE submission_id='".$submission_id."'");
$result mysql_query($query)
    or die(
"select from table ".$g_table_prefix."form_".$form_id." not successful: ".

// create missing fields
$columns = array(
'mc_gross'            => "varchar(20)",
'mc_fee'            => "varchar(20)"
$columns as $key => $value)
// checks if any field(s) already exist in table
$query = ("SHOW COLUMNS ".
"FROM ".$g_table_prefix."form_".$form_id." ".
"LIKE '".$key."'");
$result mysql_query($query)
            or die(
"show columns from table ".$g_table_prefix."form_".$form_id." failed: ".
$col mysql_fetch_array($result);
NULL == $col[0])
// create new field(s) and specify datatype and position in table
$query = ("ALTER TABLE ".$g_table_prefix."form_".$form_id." ".
"ADD COLUMN ".$key." ".$value." ".
"AFTER is_finalized;");
$result mysql_query($query)
                or die(
"altering table ".$g_table_prefix."form_".$form_id." add column failed: ".
// update ft_form_fields table

//more code 

Works great!

But I need these newly created fields (or columns) and their corresponding entries to appear from within formtools. Am I correct in assuming that I need to update the ft_form_fields table to reflect this update(?). If so, is there anything else I need to consider, update or be wary of?

Any assistance you'd be willing to provide would be hugely appreciated, Ben.

Messages In This Thread
Manually appending new fields to a form using PHP - by crunchers - Apr 27th, 2011, 3:18 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)