Join Form required field compare to database value

A new join form required field must be compared to a database of allowable values.  If the field data matches a value in a database table of allowable entries, the join form creates the profile if a profile does not already exist with that data value.

Check field input against allowable values as stored in database; if allowable value, check profiles to see if value has already been used; if allowable value has not been used, create profile.

Checking to see if a profile already exists with the value is easy, no different than checking to see if the email is already in use.  It is the first part, checking the value against a table of allowable values that I could use a bit of feedback on.  I am guessing the join form needs to grab the values stored in the database table and store that in an array which then the join form field can use to check the entered values.  Not really sure how to approach this one.  Might need a bit of ajax to check the value of the input as it is entered, or after focus of the input is changed.

Geeks, making the world a better place
Quote · 20 Mar 2013

Hello!

You could try the simple approach here. Take this from the spam blocker script http://www.boonex.com/forums/topic/spam-spam-spam-spam-IDEA-.2.htm

and your function maybe look like this, from what i have understand so far

may need adjustment for what you want....:D

function checkIfInputAllowed($sValue)
{
      $sValue = strtolower(trim($sValue));
      if(!$sValue) return false;
      $aAllowedValues = array('cat', 'dog', 'door', 'rat');
      foreach($aAllowedValues as $sAllowedValue)
      {
           if($sAllowedValue == $sValue)
                 return true;
      }
      return false;

so much to do....
Quote · 20 Mar 2013

Thanks for the input.  This is for the person that posted about Liberation_key and I am just trying to help them recover what they had since it seems to be lost.  I have searched their files and database and it appears that when TMD did their upgrade they lost this from the site; I found reference to a database that is no longer on the site as well.  Plus, the site structure is a bit of a mess with Dolphin installs inside of Dolphin installs; I don't know TMD but looking at this person's mess it makes me wonder who created it, TMD or the owner.

There are literally hundreds of keys, at least some 500+ keys in the database as I did a quick scan; maybe more.  It has to check to see if the key the person is entering is a valid key against the keys stored in the database.  If the key is valid, then when the join form is submitted the "check" field in the join form can check to see if that key has already been used; that a profile exists that is using that key; in other words, keys can not be shared.

Geeks, making the world a better place
Quote · 20 Mar 2013

Here is something you can work on Wink

function checkIfInputAllowed($sValue)
{
      $sValue = strtolower(trim($sValue));
      if(!$sValue) return false;
      $sValue = process_db_input($sValue);

     // Check if the value even exists in the allowed values
     $iValueExist = $GLOBAL['MySQL']->getOne("SELECT `ID` FROM `values_list` WHERE `value` = '$sValue'");
     if(!empty($iValueExist))
          return false;

     // Check to see if a profile already took this value
     $iProfileUsed = $GLOBAL['MySQL']->getOne("SELECT `ID` FROM `Profiles` WHERE `whatever_field` = '$sValue'");
     if(!empty($iProfileUsed))
          return false;
      
     // The given value is valid and not used up yet, we are good lets be happy
     return true;
}

so much to do....
Quote · 20 Mar 2013

Thank you.  This should give me a start on providing them with a solution.

Geeks, making the world a better place
Quote · 20 Mar 2013

You're very welcome :D

Thank you.  This should give me a start on providing them with a solution.

 

so much to do....
Quote · 20 Mar 2013

I can not seem to get the "check" to call the function.  The form does not process.

Got a message from the person that I was trying to help they needed it by this afternoon or they would pay someone to do it.  Funny, they did not say anything about paying me for my time.

Still, would like to know how to get this accomplished as it might be useful for my own purposes.

Geeks, making the world a better place
Quote · 21 Mar 2013

Oh i thought you would be able to do the check thingy from the other post but nvm

Put the code in join.php or design.inc.php anyone

return (checkIfInputAllowed($arg0)) ? true : false;

This goes in the field check field.

so much to do....
Quote · 21 Mar 2013

Thanks, I see what I did wrong now.  Let me try what you provided.

Geeks, making the world a better place
Quote · 21 Mar 2013

Still not go; the form just sits there when the submit button is pressed.  I read through the post you sent and saw where some had problems as well related.  If I clear the check field the form will process.

Geeks, making the world a better place
Quote · 21 Mar 2013

I see Unique: in the form builder; that means I don't need to check to see if the key has already been used, the form processor will do that for me.

Geeks, making the world a better place
Quote · 21 Mar 2013

Can i have the link to the join form?

so much to do....
Quote · 21 Mar 2013

Sent you a PM.  I can see where this would be useful in other ways.  I could close my site to anyone that does not have an invitation key; if coupled with an expiration for the key; one could send out an invitation key that could only be used for 24 hours to register on the site.

Please let me know the solution here.

Geeks, making the world a better place
Quote · 21 Mar 2013

er....please fix this

$GLOBAL['MySQL'] === $GLOBALS['MySQL']

I forgot the "S" lol

so much to do....
Quote · 21 Mar 2013

OK

Geeks, making the world a better place
Quote · 21 Mar 2013

Well, while that may have been an error, it is still not working.  I have tried several things but nothing I put allows the form to be processed; that check field seems to be preventing the form from even being sent to the form processor.

Geeks, making the world a better place
Quote · 21 Mar 2013

Ok, sit tight i am going in to find and fix this.

so much to do....
Quote · 21 Mar 2013

Thanks, perhaps this will be useful to others as well.  When we get it all sorted, we can present the final results here.

Geeks, making the world a better place
Quote · 21 Mar 2013

Fixed, you didn't updated the column in the query and fixed a logic error.

so much to do....
Quote · 21 Mar 2013

 

Fixed, you didn't updated the column in the query and fixed a logic error.

Could you expand on this please?

Geeks, making the world a better place
Quote · 21 Mar 2013

I forgot to replace value with the actual entry. Embarassed

Geeks, making the world a better place
Quote · 21 Mar 2013

What? What to do ???Tongue Out

so much to do....
Quote · 21 Mar 2013

I know basic mySql query; so I should have seen that.  What was the logic that you fixed?

Geeks, making the world a better place
Quote · 21 Mar 2013

if(!empty($iValueExist))

Should be

if(empty($iValueExist))

I was tying here directly and didn't even run this code so my bad :P

EDIT: Oh and you didn't update the "value" column to "LIBERATION_KEY"

so much to do....
Quote · 21 Mar 2013

Yes, I caught the error of not putting the column required.

Geeks, making the world a better place
Quote · 21 Mar 2013

To bring it all together:

function checkIfInputAllowed($sValue)
{
      $sValue = strtolower(trim($sValue));
      if(!$sValue) return false;
      $sValue = process_db_input($sValue);

     // Check if the value even exists in the allowed values
     $iValueExist = $GLOBALS['MySQL']->getOne("SELECT `ID` FROM `table` WHERE `column` = '$sValue'");
     if(empty($iValueExist))
          return false;
     
     // The given value is valid, we are good lets be happy
     return true;
}

Table is replaced with the actual table in the database; and column is replaced with the column to check in that table.

In the form builder for the join form click on the name of the input field on the join form.  Click on advance tab and in the "check" field add:

return (checkIfInputAllowed($arg0)) ? true : false;

Many thanks Prashank25 for your help on this.  I am sure the one I was helping has many thanks to offer as well.

Geeks, making the world a better place
Quote · 21 Mar 2013

Hello,

 

I came here to give very thank you. 

We solved the problem thanks to you guys:  and 

 

Mila 

Quote · 22 Mar 2013

I got an email outlining the Liberation Key is case sensitive.  So a key with FF34 is a different key than ff34.  How do we handle case sensitive keys?

Geeks, making the world a better place
Quote · 22 Mar 2013

Why do we change the value to lower case? strtolower?  Do I simply remove that and keep the trim in place?

Geeks, making the world a better place
Quote · 22 Mar 2013

MySql normally does not care about case during select. There are many things that can be done. One would be to change the collation of that table to one that is case sensitive. The other would be to change the field to type binary.

The easiest method may be this. Change your query from this.

$iValueExist = $GLOBALS['MySQL']->getOne("SELECT `ID` FROM `table` WHERE `column` = '$sValue'");


To This


$iValueExist = $GLOBALS['MySQL']->getOne("SELECT `ID` FROM `table` WHERE BINARY `column` = '$sValue'");


Adding the BINARY keyword should force it to use a binary search method which should do what you want. Only way to know for sure is to test it.

https://www.deanbassett.com
Quote · 22 Mar 2013

 

Why do we change the value to lower case? strtolower?  Do I simply remove that and keep the trim in place?

 Umm yea, you don't want to do that. It will force the string to lowercase. So yea, remove it if you need to maintain case.

Change this.

$sValue = strtolower(trim($sValue));

To This.

$sValue = trim($sValue);


You will most likely still need the binary query i mentioned above.


https://www.deanbassett.com
Quote · 22 Mar 2013

Thanks for the help, it is now working as it should.

Geeks, making the world a better place
Quote · 22 Mar 2013

Thank you Deano and Geek Girl  to help. Work perfect. 

 

Mila

Quote · 22 Mar 2013

Thanks GG and Prashank. because of your efforts, I have successfully changed the process I was using so that now only those with authorized numbers are allowed to create thanks. Keep up the great help and insight.

caredesign.net
Quote · 10 Oct 2013
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.