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] Trying to access array offset on value of type null - Line: 488 - File: inc/db_mysqli.php PHP 8.1.27 (Linux)
File Line Function
/inc/db_mysqli.php 488 errorHandler->error
/showthread.php 722 DB_MySQLi->fetch_field
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 "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:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Re-Edit Form?
#1
I have a very complicated form (multi-page form using the API) which some users will not fill out all in one go. Instead they will need to complete it over a few days. I’d like to know if it’s possible for someone to submit the form on say a Monday and then the following day log in with a user name and password and continue editing it.

I’ve had a look at the Submission Accounts module but don’t think this is suitable because I can’t use it with the original form I have created. Is this right?

What I was hoping was there there’s a way that I could use one of the API functions to re-load all the $fields values for a submitted form so that the user could then re-edit the form?

Thanks in advance.
Reply
#2
Hi Spenny,

Sure! Actually I do this very thing for a few clients. I wrote the Submission Accounts module because people generally aren't that technical and it allows for this functionality without delving into any PHP - but it's NOT a perfect solution, I'll be the first to admit. And yes, you're right - the module doesn't use the original form.

If you're interested, post me back and when I get home tonight I'll locate some code for you. If memory serves it's not TOO tricky to get up and running; but it will require you a separate login form for your form. I'll explain that later...

- Ben
Reply
#3
Hi Ben,

That's sounds perfect! I'd be most grateful for the code that allows this. While I am not an expert PHP coder, I'm cetainly willing to have a go at configuring some code and setting up the login form.

Kind regards
Spenny
Reply
#4
Ah yes! Thanks for the reminder. Let me try and find an example now...

- Ben
Reply
#5
Alright! Here we go. I've tried to abstract away most of the details so you can just drop it into your own form with only a few minor changes. Not sure if it'll work precisely as planned, but let's give it a go.

What you need to do is add a new login form, say "login.php". This should contain the following - obviously you can separate the PHP and HTML if - I just stuck it a single file for this example for convenience.

The idea is that all users going to your form will be faced with a login form off the bat. New users who haven't registered yet can use the default password (usually I just display it on the page). Existing users can log in with their own password - which they would have changed on page 1 of your own form.

Well, code first. Explanation below:

PHP Code:
<?php

$folder 
dirname(__FILE__);
require_once(
"$folder/../admin/global/api/api.php");
ft_api_start_sessions();

$form_id 53;
$username_field "attendee_email"// the database column that's acting as your "username" field.
$password_field "password"// the database column acting as your "password" field
$default_password "pass123"// our default password. This allows anyone to register using this password, which they can change during the reg process


$email "";
if (isset(
$_POST["email"]) && !empty($_POST["email"]))
{
    
$email    ft_sanitize($_POST["email"]);
    
$password ft_sanitize($_POST["password"]);

    
// try to locate the user
    
$query mysql_query("
      SELECT *
      FROM   
{$g_table_prefix}form_{$form_id}
      WHERE  
$username_field = '$email' AND
             
$password_field = '$password'
        "
);
  
$result mysql_fetch_assoc($query);

  if (empty(
$result))
  {
      if (
$password != $default_password)
      {
        
$g_success false;
        
$g_message "Sorry, we couldn't locate that email/password combination. Please try again.";
      }
    else
    {
          
// this is a new registrant" create a record for them
          
if (empty($result))
          {
              
$default_values = array(
                
"attendee_status" => "Incomplete",
                
"$username_field=> $email,
                
"$password_field=> $default_password
              
);
              
$result["submission_id"] = ft_api_create_blank_submission($form_idtrue$default_values);
          }

          
$_SESSION["form_tools_form"] = $result;
          
$_SESSION["form_tools_form"][$username_field] = $email;
          
$_SESSION["form_tools_form"]["attendee_status"] = "Incomplete"// sets the form field "attendee_status" as 
          
$_SESSION["form_tools_form"]["form_tools_form_id"]       = $form_id;
          
$_SESSION["form_tools_form"][$password_field]       = $default_password;
          
$_SESSION["form_tools_form"]["form_tools_submission_id"] = $result["submission_id"];
          
header("location: step1.php");
          exit;
    }
  }
  else
  {
      
$_SESSION["form_tools_form"] = $result;
      
$_SESSION["form_tools_form"][$username_field] = $email;
      
$_SESSION["form_tools_form"]["form_tools_form_id"]       = $form_id;
      
$_SESSION["form_tools_form"]["form_tools_submission_id"] = $result["submission_id"];
      
header("location: step1.php");
      exit;
  }
}
?>
<html>
<head>
</head>
<body>

<h1>Log In</h1>

<?php
if ($g_message) echo $g_message;
?>

  <form method="post" action="<?=$_SERVER["PHP_SELF"]?>" name="login">

    <div class="" style="padding-top: 3px; width:400px">
        <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
              <td width="120" class="blue">Email:</td>
              <td><input type="text" size="25" name="email" id="email" value="<?=$email?>" tabindex="1" /></td>
                <td width="80" align="center" rowspan="2">
                  <input type="submit" value="LOG IN" tabindex="3" />
                </td>
            </tr>
        <tr>
              <td class="blue">Password</td>
              <td><input type="password" size="25" name="password" value="" tabindex="2" autocomplete="no" /></td>
            </tr>
        </table>
      </div>

  </form>
</body>
</html> 

1. Update this line to point to your own api.php location:
require_once("$folder/../admin/global/api/api.php");

2. Set the $form_id to your own form ID.

3. Change these three fields to store the database column names of the fields that are going to act as the user's login username and password. In order to uniquely identify the user for when they log back in, these two are required. I always use "email" as a username field - simplest that way.

$username_field = "attendee_email";
$password_field = "password";

Also: I'm pretty sure the code requires your form fields to have the same database column names. I.e. your email field has a name attribute of "attendee_email" AND your database column for that field has the same value. I've always done this - had a 1-1 relation between form field names and database column names. It just makes working with the database that much simpler. You don't HAVE to do this, but you may have to review the code to ensure it's all okay.

4. The default password. The form I was taking this from required a default password for all new users to log in with. Once they were logged in, they could change it. If you don't need this feature, just change it to some long, indecipherable string.

$default_password = "pass123";

5. Change these lines to specify the first page in your form (there are two lines like this):
header("location: step1.php")

6. On the first page of your form you'll need to add the option to change the default password. All this requires is adding a field to your Form Tools form with the name attribute the same as specified above. And secondly, you'll need to add it to Form Tools so the information is actually stored in the database.


And I think that's it... Hope this is somewhat helpful & not too unclear.
Reply
#6
(Aug 1st, 2009, 9:28 AM)Ben Wrote: Also: I'm pretty sure the code requires your form fields to have the same database column names. I.e. your email field has a name attribute of "attendee_email" AND your database column for that field has the same value. I've always done this - had a 1-1 relation between form field names and database column names. It just makes working with the database that much simpler. You don't HAVE to do this, but you may have to review the code to ensure it's all okay.

Ben, Many thanks for this code and your detailed instructions.

I've managed to use the login.php form to successfully log in and take me to the first page of my form. However when the form opens it doesn't load the data into the $fields array as I was hoping. I think this is because the array data loaded from login.php uses the field names taken from the database columns eg col_1, col_2, col_3 eg
Array ( [col_1] => John [col_2] => Doe [col_3]=> 34)

whereas the $fields aray uses field names from my form eg
Array ( [first_name] => John [last_name] => Doe [age]=> 34)

I think this is what you refer to in the above quote - is that right?

If so, how do I fix this? Do I need to manually change all the column titles in the database to match my form (a very long process!!) or is there a way to change the code of formtools so that when I first initialise my form it automatically uses the field name on my form for the column titles instead of col_x?

I hope I have made sense!
Thanks again
Reply
#7
Ah! Good point - I forgot about that.

Actually, it's really easy to map the form names to your database col names. Just log into Form Tools, edit your form and go to the Database tab. There, click on the "Smart Fill" button. That will rename all of your form fields to make them identical to your form fields. I think maybe I rely on that & kinda forgot that I did...

The only potential problem is if your form field names are MySQL reserved words. In that case, the JS "Smart Fill" option will append a prefix or suffix to the generated field name... I forget which.

Good grief, I'm forgetting everything today.

Anyway, give that a go. Smile

- Ben
Reply
#8
Hi Ben,

That's brilliant! That SmartFill Button works like magic.

And now to the next problem... (sorry!)

When I login I am taken to the form that I have previously submitted so that I can continue editing it (so far so good...) The problem is that because this form has already been submitted, when I submit the form again it returns error #302 - the form has already been finalized.

I think I have found the code in the api.php file that checks whether the form has been finalized. The code starts on line 616

PHP Code:
// check the submission ID isn't finalized
    
if (!$may_update_finalized_submissions && ft_check_submission_finalized($form_id$submission_id))
    {
          if (
$g_api_debug)
          {
            
$page_vars = array("message_type" => "error""error_code" => 302"error_type" => "user",
                
"debugging" => "{$LANG["phrase_submission_id"]}$submission_id");
              
ft_display_page("../../global/smarty/messages.tpl"$page_vars);
              exit;
          }
          else
            return array(
false302);
    } 
What I have is done is to delete this code and it seems to works fine. But I just want to check with you that I have done the right thing and it wont mess anything up!

Thanks again!
Reply
#9
Hey Speny,

Ah! That's fine - actually no, don't delete it. Instead, just add a new key-value pair to the $params you're passing to ft_api_process_form (the last row - ignore the other rows, they're just to show the context & are probably different for you):

PHP Code:
$params = array(
  
"submit_button" => "submit_button_name_attribute",
  
"next_page" => "next_page.php",
  
"form_data" => $_POST,
  
"no_sessions_url" => "first_page_in_form.php",
  
"may_update_finalized_submissions" => true
    
);
ft_api_process_form($params); 

The "may_update_finalized_submissions" setting will override the default behaviour & allow you to update a finalized submission. Hope that helps!

- Ben
Reply
#10
edited
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)