9 Replies Latest reply on Mar 29, 2009 12:21 AM by (Laurence_Lewis)

    Random number Primary Key column

    (Laurence_Lewis) Level 1
      Hi All

      I am trying to set up a method of stopping....better I explain

      A multipart form is filled out (anyone can access this form)
      using ADDT the only way I can get the info from pageto page is form1?id=id

      If person 1 fills out the form the default primary id = 1
      If person 2 fills out the form the default primary id = 2

      However if person 2 thinks, lets see what person 1's details are, he/she/it only has to change the ID to 1

      I thought to get around this a random number would be great.

      Does anyone know how I would set the primary key to a random number using ADDT

      I will try and work this out in the meantime.

      Cheers

      Laurence
        • 1. Re: Random number Primary Key column
          Waleed Barakat Level 1
          Hi Lewis
          I think you should have to add another field which will do the job instead of the primary ID

          Like this:
          ------------

          input name="rand_id" type="hidden" id="rand_id"
          value=""

          as you can see the value of the hidden filed is generate at least 6 different digits every time the new user added, then you can move to use this new generated ID as your primary ID.

          __
          Best Regards
          Waleed Barakat
          Developer-Online Creator and programmer
          http://www.developer-online.com
          • 2. Re: Random number Primary Key column
            (Laurence_Lewis) Level 1
            Hi Waleed

            Firstly greetings and ggood health to the esteemed waleed.
            Please excuse my ignorance but how does this work?

            I retain the primary key ans 1,2,3 4...

            And in the form I set a hidden field as you set

            input name="rand_id" type="hidden" id="rand_id"
            value=""

            If I am thinking correctly this will pass the mt-rand with the primary key throughout the form until its final submission to the DB ID 1
            Then a new entry ID2 will create a new hidden random (rand_id) and even if person 2 changes the URL to .php?id=1 it will not display the details because the random field is different??

            Cheers
            laurence
            • 3. Re: Random number Primary Key column
              (Laurence_Lewis) Level 1
              Gunter and Albert your esteemed to but this is the first post Waleed has answered :-; <br /> <br />Im trying to work this out <br /> <br />My currrent primary key is set as <br />$ins_membership-&gt;setPrimaryKey("id_mship", "NUMERIC_TYPE"); <br /> <br />If I add Waleed's hidden field to the form <br /> <form> <input name="rand_id" type="hidden" id="rand_id" value="<?php echo mt_rand() . " />" /&gt; <br /> <br />and to quote <br />as you can see the value of the hidden filed is generate at least 6 different digits every time the new user added, then you can move to use this new generated ID as your primary ID. <br /> <br />I could spend hours working this out and get nowhere <br /> <br />Some time later <br /> <br />I think I get it I leave the id_mship to auto increment and I add rand_id as the Primary key in the db. <br /> <br />Not sure if I got that right but going to try it anyway <br /> <br />L</form>
              • 5. Re: Random number Primary Key column
                (Laurence_Lewis) Level 1
                I did not have success.

                I understand the concept just have to get it to work

                L
                • 6. Re: Random number Primary Key column
                  Albert S. Level 3
                  Hi Laurence,

                  To give the best advice I think if you wrote down the bigger picture of what you are trying to do. I have a couple questions.

                  Is this a form for Members only?
                  Is this a Dynamic Form (Dynamic Forms have the ability for insert and update) or just an Insert form or just an Update form?

                  :)
                  • 7. Re: Random number Primary Key column
                    (Laurence_Lewis) Level 1
                    Hi Albert

                    The form is an application for people to become members

                    The first page form is an insert

                    $ins_membership->registerTrigger("END", "Trigger_Default_Redirect", 99, "personal-details.php?id_mship={id_mship}");

                    the second page "personal-details" updates the same table row.

                    Using this normally the id_mship column auto increments and is the primary key. What i am trying to achieve is that instead of auto-incrementing 1,2,3.... its randomly generated.

                    Waleed suggested I could use " /> in a hidden field for this.

                    I am not sure if i am approaching this the best way so any advise would be appreciated.

                    Cheers
                    Laurence
                    • 8. Re: Random number Primary Key column
                      Albert S. Level 3
                      Hi Laurence,

                      My first thought would be to go over this tutorial.

                      Straight to tutorial:

                      http://www.interaktonline.com/Documentation/MXKollection/076200_tutorialuserauthentication .htm

                      All of the online documentation: (Keep in mind this was when ADDT was MXKollection) So if you encounter differences use your best judgment.

                      http://www.interaktonline.com/Documentation/MXKollection/

                      My thinking is...

                      1. User goes to register, they fill out form 1 (email, name, etc).
                      2. Values from form 1 get carried to form 2 (hidden values, session or post) then they fill out form 2. (Address, phone, etc).
                      3. Completion of form 2 has 1 insert trigger to enter in all data from both forms.

                      Basically at this point the user has entered all profile information and is waiting on confirmation email to accept membership.

                      Then in the membership side they can edit their profile based on an total authentication system. Because if you don't have one in place users will always be able to manipulate your $_GET values to see other peoples data.
                      • 9. Re: Random number Primary Key column
                        (Laurence_Lewis) Level 1
                        Thanks Albert I'll set it up as you suggest