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
Update submittion with API
#1
Hi,
As newbe, I'm integrating Formtools API with my login script (login script just to control form access like other part of my site) and found a way to create a blank submission and retrieve "submission_id" and add it to my user table.

actually there is a way to get and show submitted data with "submission ID", "ft_api_show_submission".

But, how I Update that ID with new information using API?

Thank You
Reply
#2
Hi Poorya,

A better way to manage access to your forms is to use the Submission Accounts module: http://modules.formtools.org/submission_accounts/

Cheers,

Joe
Reply
#3
(Apr 22nd, 2014, 10:31 AM)Joe Wrote: Hi Poorya,

A better way to manage access to your forms is to use the Submission Accounts module: http://modules.formtools.org/submission_accounts/

Cheers,

Joe

Thank you,

Thats right,
but I have multiple forms for each user that I need to link them to user and I did not find how to make that.
For example, when my user fills form1, then logins with user and password from that form, how to give them access to data submited in form2 or form3?

Actually, I found that I can save submission_id in my login script table and then, add that to '$_SESSION["form_tools_form"]["form_tools_submission_id"]' and load previous submission with "ft_api_get_submission" and resend that to update with ft_api_process_form.

I found that while there is a '$_SESSION["form_tools_form"]["form_tools_submission_id"]' submitions update this '$_SESSION["form_tools_form"]["form_tools_submission_id"]'


My code is like: (Code edited)
[undefined=undefined]
require('/loginscript/includes/config.php');
//if not logged in redirect to login page
if(****){ header('Location: ***'); }

//check for prev submission
$stm = **SELECT * FROM logintable WHERE memberID = **;
$stm->execute(array('**' => $_SESSION['memberID']));
$rww = $stm->fetch(PDO::FETCH_ASSOC);


//if already set : please review
if(isset($rww['submissionid'])){
//just NOT valid as an ID
if($rww['submissionid'] <= 0){
require_once("../global/api/api.php");
$default_values = array(
"firstname" => $_SESSION['firstname'],
"lastname" => $_SESSION['lastname'],
"email" => $_SESSION['email']
);
//add blank submission for user, and get submissionid
$submission_id = ft_api_create_blank_submission(***, true, $default_values);

//add form submition id to member db
$stmt = ***UPDATE *** SET firstform = *** WHERE memberID = :memberID");
$stmt->execute(array(
'***' => $submission_id,
':memberID' => $_SESSION['memberID']
));

//if the row was updated redirect the user
if($stmt->rowCount() == 1){
****
} else {
echo "there is an error";
}
//if a valid submition found
} elseif($rww['submissionid'] > 0) {


require_once("../global/api/api.php");

//set submissionid to session variable
$_SESSION["form_tools_form"]["form_tools_submission_id"] = $roww['firstform'];
$_SESSION["form_tools_form"]["form_tools_form_id"] = '***';

//if valid submition found and there is a Update
if (isset($_POST["val"]) && ($_POST["val"] == "update1")) {

//prepare to apdate submition
$fields = ft_api_init_form_page(3);
$params = array(
"submit_button" => "submit",
"next_page" => "thankyoupage.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true
);
ft_api_process_form($params);
}

// get submitted data to load to form
$submission_info = ft_api_get_submission(***, $roww['submissionid']);

// echo "Please review your registration";
}}else{
// echo "there is an error! Please contact administrator";
// die;
}

[/undefined]


Thank you again for your great App. Smile)
Reply
#4
A form tool is shaped out for the benefits for the visitors of the links. The elevation of the show of the tool and best essays is hatched for the durable signs for the workers. Now, the tool of the form is changing for the modern requirements for the homes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)