The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
newbie submit form question - 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: newbie submit form question (/showthread.php?tid=936) |
newbie submit form question - jguerra - Nov 14th, 2010 Ok, sorry if this is already answered in docs, but I couldn't find explicit examples, and want to make sure I am in the ballpark.. I have a form I have created to submit values to an existing database, but I need these values in separate tables. Can I do this using the $fields array and a sql statement? example form header: require_once("../formtools/global/api/api.php"); $fields = ft_api_init_form_page(1); $params = array( "submit_button" => "add_intake", "next_page" => "thanks.php", "form_data" => $_POST, // "file_data" => $_FILES, "finalize" => true ); ft_api_process_form($params); ?> then do my insert into sql based on $fields['field_name'] $qresult = mysql_query("update table where key = $fields['key]"); if (mysql_num_rows($qresult) == 0) { basically, I want to map the fields in the form to an existing database rather than using the formtools ft_ tables.. Would it make more sense to just link the ft_ table to my existing table instead and do some kind of post-processing thing? Sorry if this is unclear or a stupid question, I am a bit new to this. would I do this as part of the form itself or could I separate this code? RE: newbie submit form question - Ben - Nov 20th, 2010 Hi jguerra, Interesting problem! Quote:Would it make more sense to just link the ft_ table to my existing table instead and do some kind of post-processing thing? That's how I'd tackle it, yes. Form Tools pretty much revolves around the idea of the fact that it creates and manages it's own database tables. Trying to circumvent that and getting it to link to a non-Form Tools-built table isn't a good idea - you'd have too many problems. Instead, doing some sort of There's a few ways you could do it, but none are terribly simple. You'd definitely need a programmer handy. 1. One would be to add some sort of trigger on the MySQL table that runs a custom script when a new row is inserted. This script would copy that data over to your custom table. I know this is possible, but I'm afraid I haven't done this myself so don't have much advice. 2. Write a separate PHP script that you could run that does the same. In this case, you would also need to keep track of what records have already been copied over. I'd suggest either logging the submission ID somewhere in a log file, or actually storing the submission ID in the new table - to prevent copying over records multiple times. Sorry for the rather high-level advice, but it'll take a little work to get this working as you need! - Ben |