The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (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.31 (Linux)
File Line Function
/showthread.php(732) : eval()'d code 5 errorHandler->error
/showthread.php 732 eval
Warning [2] Undefined variable $postsdone - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Trying to access array offset on value of type null - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 907 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 912 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 921 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 922 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 934 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 940 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 965 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 997 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 3833 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 3851 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 3859 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 4707 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 5006 - Line: 867 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 867 errorHandler->error
Warning [2] Undefined array key 907 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 912 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 921 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 934 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 940 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 965 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 5006 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 3833 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 3851 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key 4707 - Line: 1576 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/showthread.php 1576 errorHandler->error
/showthread.php 1578 buildtree
/showthread.php 1578 buildtree
/showthread.php 879 buildtree
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (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 880 build_postbit
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(474) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php(474) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 474 eval
/showthread.php 880 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 660 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 660 errorHandler->error
/showthread.php 880 build_postbit
Warning [2] Undefined array key "showimages" - Line: 741 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 741 errorHandler->error
/showthread.php 880 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 746 - File: inc/functions_post.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions_post.php 746 errorHandler->error
/showthread.php 880 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1506 - File: showthread.php PHP 8.1.31 (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.31 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 30 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $multipage - Line: 33 - File: showthread.php(1533) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 33 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $multipage - Line: 65 - File: showthread.php(1533) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/showthread.php(1533) : eval()'d code 65 errorHandler->error
/showthread.php 1533 eval
Warning [2] Undefined variable $addremovesubscription - Line: 79 - File: showthread.php(1533) : eval()'d code PHP 8.1.31 (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?
#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


Messages In This Thread
Re-Edit Form? - by spenny - Jul 26th, 2009, 11:28 PM
RE: Re-Edit Form? - by Ben - Jul 28th, 2009, 10:38 AM
RE: Re-Edit Form? - by spenny - Jul 29th, 2009, 5:07 AM
RE: Re-Edit Form? - by Ben - Aug 1st, 2009, 9:02 AM
RE: Re-Edit Form? - by Ben - Aug 1st, 2009, 9:28 AM
RE: Re-Edit Form? - by spenny - Aug 5th, 2009, 4:45 AM
RE: Re-Edit Form? - by Ben - Aug 6th, 2009, 5:44 PM
RE: Re-Edit Form? - by spenny - Aug 11th, 2009, 6:39 AM
RE: Re-Edit Form? - by Ben - Aug 15th, 2009, 2:21 PM
RE: Re-Edit Form? - by heywood7 - May 26th, 2011, 1:43 PM
RE: Re-Edit Form? - by greatwhitebuffalo - Dec 9th, 2010, 9:24 AM
RE: Re-Edit Form? - by greatwhitebuffalo - Dec 10th, 2010, 1:18 PM
RE: Re-Edit Form? - by greatwhitebuffalo - Dec 12th, 2010, 8:39 AM
RE: Re-Edit Form? - by akeane - Apr 26th, 2011, 12:12 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)