(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.

)