The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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.27 (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
Can't have two actions with one submit POST..
#1
Greetings. I currently have a php script that runs when a form I created is submitted. Basically the script posts the collected data to a second external form and submits it there. Now I want to add Form Tools in order to create a more aesthetically appealing front end and user friendly back end with database support etc. -- I've used FT before, however, never with the involvement of a second PHP script that reroutes the info.

At this point, Form Tools is waiting for a test submission from your form. It will use this form submission to know what information should be stored for all future submissions. They give me two options to add my code.. by PHP or API..

PHP is what I usually use, as it's just a matter of adding
Quote:<form action="http://www.mysite/formtools/process.php" method="post">
<input type="hidden" name="form_tools_initialize_form" value="1" />
<input type="hidden" name="form_tools_form_id" value="1" />

But now I have a problem because, currently, my submit button

Quote:<form method="post" action="formload.php">
<input type="submit" class="primaryAction" id="submit-" name="tfa_submitAction" value="submit">
<input type="hidden" value="294-ebbb9c4d4e37fd131788e258d9663332" name="tfa_dbCounters" id="tfa_dbCounters">
<input type="hidden" value="134518" name="tfa_dbFormId" id="tfa_dbFormId">
<input type="hidden" value="" name="tfa_dbResponseId" id="tfa_dbResponseId">
<input type="hidden" value="b40a6b1b2518fdfbbf03a9951e71ea75" name="tfa_dbControl" id="tfa_dbControl">
<input type="hidden" value="1278748831" name="tfa_dbTimeStarted" id="tfa_dbTimeStarted">
<input type="hidden" value="53" name="tfa_dbVersionId" id="tfa_dbVersionId">

So I was told both scripts can't be called in this fashion (two actions from one submit post) but could instead be combined into one .php script - Thanks admin thorpe

Being that I'm a new comer to PHP and I didn't write either of these scripts, I don't want to haphazardly combine both scripts and break either one, especially the first. Can someone help me out in discovering the best way to integrate my current PHP file with Form Tool?

My current code looks like this:


Quote:<?

// Get the post data..
$postdata = file_get_contents("php://input");

if($_POST['tos'] != "on")
{
echo("<h2>You MUST accept the Terms of Service to submit this form</h2>");
die();
}

// Extract TOS from post string..
$postdata = preg_replace("/&tos=on/","",$postdata);

// Fetch original form to substitute changable post variables..
$chA = curl_init();
$timeout = 5;
curl_setopt ($chA, CURLOPT_URL,"url removed");
curl_setopt ($chA, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($chA, CURLOPT_CONNECTTIMEOUT, $timeout);
$pagedata = curl_exec($chA);
curl_close($chA);

// Use regular expression to extract data in tfa_dbCounters..
preg_match("/value=\"([a-zA-Z0-9-]+)\" name=\"tfa_dbCounters\"/",$pagedata, $matches);
$dbcounters = $matches[1];

// Now fetch and substitute form ids and such..
$timestamp = time();
$postdata = preg_replace("/&tfa_dbTimeStarted=\d+/","&tfa_dbTimeStarted=$timestamp",$postdata);
$postdata = preg_replace("/&tfa_dbCounters=[a-zA-Z0-9-]+/","&tfa_dbCounters=$dbcounters",$postdata);

// Repost the postdata from the first form to the final destination..
$chB = curl_init("url removed");
curl_setopt($chB, CURLOPT_POST, 1);
curl_setopt($chB, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($chB, CURLOPT_HEADER, 0);
curl_setopt($chB, CURLOPT_RETURNTRANSFER, 1);
$Rec_Data = curl_exec($chB);

// Create an HTML header..
ob_start();
header("Content-Type: text/html");

// Get rid of bogus characters and linefeeds..
$Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
$Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output));
$Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output);

// Chop off the rest of the header garbage..
$Temp_Output = substr($Temp_Output,197,300);

// Construct email
$splitData = explode("&",$postdata);

$email = "Form Submission Email\n\n";
$email = $email . "Submission from [" . $_SERVER['REMOTE_ADDR'] . "]\n";
$email = $email . "---------------------------------------------------------\n";

foreach($splitData as $datum)
{
$datum = preg_replace("/\+/"," ",$datum);
$datum = preg_replace("/%5B/","[",$datum);
$datum = preg_replace("/%5D/","]",$datum);
$email = $email . "$datum\n";
}

$email = $email . "---------------------------------------------------------\n\n";

// Send email..
mail($_POST['recipient'],"Form Submission From [" . $_SERVER['REMOTE_ADDR'] . "]",$email);

// Echo result..
echo $Temp_Output;

// Finish up..
$Final_Out=ob_get_clean();
echo $Final_Out;
curl_close($chB);

// Done.

?>


The code I want to add is this...
Quote:<?php

/**
* File: process.php
*
* This file processes any form submissions for forms already added and configured within Form Tools. To
* use it, just point your form to this file, like so:
*
* <form method="post" action="/path/to/process.php">
*
* Once the form has been added through the Form Tools UI, this script parses the form contents
* and adds it to the database then redirects the user to whatever page is required. In addition,
* this script is used to initially set up the form within the database, to map input fields to
* database columns and types.
*/


$folder = dirname(__FILE__);

// always include the core library functions
require_once("$folder/global/library.php");

// if the API is supplied, include it as well
@include_once("$folder/global/api/api.php");


// check we're receiving something
if (empty($_POST))
{
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_post_vars"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}

// check there's a form ID included
else if (empty($_POST["form_tools_form_id"]))
{
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_form_id"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}

// is this an initialization submission?
else if (isset($_POST["form_tools_initialize_form"]))
ft_initialize_form($_POST);

// otherwise, it's a regular form submission. Process it!
else
ft_process_form($_POST);

// -------------------------------------------------------------------------------------------------

/**
* This function processes the form submissions, after the form has been set up in the database.
*/
function ft_process_form($form_data)
{
global $g_table_prefix, $g_multi_val_delimiter, $g_query_str_multi_val_separator, $g_root_dir, $LANG,
$g_api_version, $g_api_recaptcha_private_key;

// ensure the incoming values are escaped
$form_data = ft_sanitize($form_data);

$form_id = $form_data["form_tools_form_id"];
$form_info = ft_get_form($form_id);

extract(ft_process_hooks("start", compact("form_info", "form_id", "form_data"), array("form_data")), EXTR_OVERWRITE);

// check to see if this form has been completely set up
if ($form_info["is_complete"] == "no")
{
$page_vars = array("message_type" => "error", "message" => $LANG["processing_form_incomplete"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}

// check to see if this form has been disabled
if ($form_info["is_active"] == "no")
{
if (isset($form_data["form_tools_inactive_form_redirect_url"]))
{
header("location: {$form_data["form_tools_inactive_form_redirect_url"]}");
exit;
}

$page_vars = array("message_type" => "error", "message" => $LANG["processing_form_disabled"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}

// do we have a form for this id?
if (!ft_check_form_exists($form_id))
{
$page_vars = array("message_type" => "error", "message" => $LANG["processing_invalid_form_id"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}


// was there a reCAPTCHA response? If so, a recaptcha was just submitted. This generally implies the
// form page included the API, so check it was entered correctly. If not, return the user to the webpage
if (isset($g_api_version) && isset($form_data["recaptcha_response_field"]))
{
$passes_captcha = false;
$recaptcha_challenge_field = $form_data["recaptcha_challenge_field"];
$recaptcha_response_field = $form_data["recaptcha_response_field"];

$folder = dirname(__FILE__);
require_once("$folder/global/api/recaptchalib.php");

$resp = recaptcha_check_answer($g_api_recaptcha_private_key, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);

if ($resp->is_valid)
$passes_captcha = true;
else
{
// since we need to pass all the info back to the form page we do it by storing the data in sessions. Enable 'em.
@ft_api_start_sessions();
$_SESSION["form_tools_form_data"] = $form_data;
$_SESSION["form_tools_form_data"]["api_recaptcha_error"] = $resp->error;

// if there's a form_tools_form_url specified, redirect to that
if (isset($form_data["form_tools_form_url"]))
{
header("location: {$form_data["form_tools_form_url"]}");
exit;
}
// if not, see if the server has the redirect URL specified
else if (isset($_SERVER["HTTP_REFERER"]))
{
header("location: {$_SERVER["HTTP_REFERER"]}");
exit;
}
// no luck! Throw an error
else
{
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_form_url_for_recaptcha"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}
}
}


// get a list of the custom form fields (i.e. non-system) for this form
$form_fields = ft_get_form_fields($form_id);

$custom_form_fields = array();
foreach ($form_fields as $field_info)
{
$field_id = $field_info["field_id"];
$field_name = $field_info["field_name"];
$col_name = $field_info["col_name"];
$field_title = $field_info["field_title"];
$field_type = $field_info["field_type"];
$include_on_redirect = $field_info["include_on_redirect"];

// ignore system fields
if ($field_type == "system")
continue;

$custom_form_fields[$field_name] = array(
"field_id" => $field_id,
"col_name" => $col_name,
"field_title" => $field_title,
"include_on_redirect" => $include_on_redirect,
"field_type" => $field_type
);
}


// now examine the contents of the POST/GET submission and get a list of those fields
// which we're going to update
$valid_form_fields = array();
while (list($form_field, $value) = each($form_data))
{
// if this field is included, store the value for adding to DB
if (array_key_exists($form_field, $custom_form_fields))
{
// ignore file fields - they're handled separately
if ($custom_form_fields[$form_field]["field_type"] == "file" || $custom_form_fields[$form_field]["field_type"] == "image")
continue;

$col_name = $custom_form_fields[$form_field]["col_name"];
$query_col_names[] = $col_name;
$cleaned_value = $value;

if (is_array($value))
{
if ($form_info["submission_strip_tags"] == "yes")
{
for ($i=0; $i<count($value); $i++)
$value[$i] = strip_tags($value[$i]);
}

$cleaned_value = join("$g_multi_val_delimiter", $value);
}
else
{
if ($form_info["submission_strip_tags"] == "yes")
$cleaned_value = strip_tags($value);
}

$valid_form_fields[$col_name] = "'$cleaned_value'";
}
}


$now = ft_get_current_datetime();
$ip_address = $_SERVER["REMOTE_ADDR"];
$is_finalized = "yes";

$col_names = array_keys($valid_form_fields);
$col_names_str = join(", ", $col_names);
if (!empty($col_names_str))
$col_names_str .= ", ";

$col_values = array_values($valid_form_fields);
$col_values_str = join(", ", $col_values);
if (!empty($col_values_str))
$col_values_str .= ", ";

// build our query
$query = "
INSERT INTO {$g_table_prefix}form_$form_id ($col_names_str submission_date, last_modified_date, ip_address, is_finalized)
VALUES ($col_values_str '$now', '$now', '$ip_address', '$is_finalized')
";


// add the submission to the database (if form_tools_ignore_submission key isn't set by either the form or the
// Submission Pre-Parser module)
$submission_id = "";
if (!isset($form_data["form_tools_ignore_submission"]))
{
$result = mysql_query($query);

if (!$result)
{
$page_vars = array("message_type" => "error", "error_code" => 304, "error_type" => "system",
"debugging"=> "Failed query in <b>" . __FUNCTION__ . ", " . __FILE__ . "</b>, line " . __LINE__ .
": <i>" . nl2br($query) . "</i>", mysql_error());
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}

$submission_id = mysql_insert_id();
}


$redirect_query_params = array();

// build the redirect query parameter array. Note that we loop through the original
foreach ($form_fields as $field_info)
{
if ($field_info["include_on_redirect"] == "no" || $field_info["field_type"] == "file" || $field_info["field_type"] == "image")
continue;

switch ($field_info["col_name"])
{
case "submission_id":
$redirect_query_params[] = "submission_id=$submission_id";
break;
case "submission_date":
$settings = ft_get_settings();
$submission_date_formatted = ft_get_date($settings["default_timezone_offset"], $submission_date, $settings["default_date_format"]);
$redirect_query_params[] = "submission_date=" . rawurlencode($submission_date_formatted);
break;
case "last_modified_date":
$settings = ft_get_settings();
$submission_date_formatted = ft_get_date($settings["default_timezone_offset"], $submission_date, $settings["default_date_format"]);
$redirect_query_params[] = "last_modified_date=" . rawurlencode($submission_date_formatted);
break;
case "ip_address":
$redirect_query_params[] = "ip_address=$ip_address";
break;

default:
$field_name = $field_info["field_name"];

// if $value is an array, convert it to a string, separated by $g_query_str_multi_val_separator
if (is_array($form_data[$field_name]))
{
$value_str = join($g_query_str_multi_val_separator, $form_data[$field_name]);
$redirect_query_params[] = "$field_name=" . rawurlencode($value_str);
}
else
$redirect_query_params[] = "$field_name=" . rawurlencode($form_data[$field_name]);
break;
}
}

// now that the submission has been added to the database, upload any files that were included and
// store the file name in the appropriate field
while (list($form_field, $fileinfo) = each($_FILES))
{
if (empty($fileinfo["name"]))
continue;

if (array_key_exists($form_field, $custom_form_fields))
{
$field_id = $custom_form_fields[$form_field]["field_id"];
$field_type = $custom_form_fields[$form_field]["field_type"];

if ($field_type == "file")
list($success, $message, $filename) = ft_upload_submission_file($form_id, $submission_id, $field_id, $fileinfo);
else if ($field_type == "image")
list($success, $message, $filename) = ft_upload_submission_image($form_id, $submission_id, $field_id, $fileinfo);
}

// if required, add the filename to the redirect query params
if ($custom_form_fields[$form_field]["include_on_redirect"] == "yes")
$redirect_query_params[] = "$form_field=$filename";
}

// send any emails
ft_send_emails("on_submission", $form_id, $submission_id);

// if the redirect URL has been specified either in the database or as part of the form
// submission, redirect the user [form submission form_tools_redirect_url value overrides
// database value]
if (!empty($form_info["redirect_url"]) || !empty($form_data["form_tools_redirect_url"]))
{
// build redirect query string
$redirect_url = (isset($form_data["form_tools_redirect_url"]) && !empty($form_data["form_tools_redirect_url"]))
? $form_data["form_tools_redirect_url"] : $form_info["redirect_url"];

$query_str = "";
if (!empty($redirect_query_params))
$query_str = join("&", $redirect_query_params);

if (!empty($query_str))
{
// only include the ? if it's not already there
if (strpos($redirect_url, "?"))
$redirect_url .= "&" . $query_str;
else
$redirect_url .= "?" . $query_str;
}

header("Location: " . $redirect_url);
exit;
}

// the user should never get here! This means that the no redirect URL has been specified
$page_vars = array("message_type" => "error", "message" => $LANG["processing_no_redirect_url"]);
ft_display_page("../../global/smarty/messages.tpl", $page_vars);
exit;
}


Any help would be TREMENDOUSLY appreciated
Reply
#2
Is there any way that I can initiate the second php script from the first one using the same post data that the first one uses? Is this a possibility?

Would this help me? Can I initiate the Form Tools from my initial PHP script? Will the post data carry over?

Quote:<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.php.net");
curl_exec ($curl);
curl_close ($curl);
?>
Reply
#3
Hi Jerry,

Sorry for not responding sooner - I've been off at a conference the last week.

This is kind of a thorny problem. Web forms just plain weren't designed to send multiple requests - just the single one, when the user submits the form.

Really the best solution would be to tackle this on the database layer: add a trigger to your table to automatically duplicate data when added/updated to your table.

Using CURL is certainly an option, but rather finicky...

May I ask, what precisely is the goal for the duplicated information? Just back-ups? If so, you might want to check out the Form Backup module. That duplicates an entire table + data.

- Ben
Reply
#4
(Jul 28th, 2010, 8:35 PM)Ben Wrote: Hi Jerry,

Sorry for not responding sooner - I've been off at a conference the last week.

This is kind of a thorny problem. Web forms just plain weren't designed to send multiple requests - just the single one, when the user submits the form.

Really the best solution would be to tackle this on the database layer: add a trigger to your table to automatically duplicate data when added/updated to your table.

Using CURL is certainly an option, but rather finicky...

May I ask, what precisely is the goal for the duplicated information? Just back-ups? If so, you might want to check out the Form Backup module. That duplicates an entire table + data.

- Ben

Hello Ben.

Here is the issue - I realized I was losing potential referrals on an external site so I came up with this form that looks almost identical to the second form with the referral field being hidden and prepopulated with my name and such, as will be outlined in the TOS. The PHP script I have linked to this fetches the second form, populates that form with my post data, and submits it there.

Do you know if there is something I can include in my php script that would launch Form Tools with the same post data? I am in a tricky situation as I need this process but I would also like to take advantage of FT.

I tried combining both scripts (I'm new to PHP) and had no luck. My idea now is this, but I would prefer an easier alternative...

[Image: couldwork.jpg]

So, do you know if this here would work? Better yet though, is there a way to simply initiate the process.php script straight from myscript.php?

Thank you for your help!
Reply
#5
Alright, so that didn't work. If I fill out my second form it thanks me for my test submit but it doesn't work when I try to post from my initial php script. Here is the code I'm using, am I doing something wrong?

Quote:// Get the post data from html form just filled out
$postdata = file_get_contents("php://input");

if($_POST['tos'] != "on")
{
echo("<h2>You MUST accept the Terms of Service to submit this form</h2>");
die();
}

//Connect to second form
$curl_connection =
curl_init('http://www.youawfulme.com/secondform.html');

//Set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $postdata);

//perform our request
$result = curl_exec($curl_connection);

//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);

//close the connection
curl_close($curl_connection);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)