I added a field to the stock registration form with a serial number field. I have a table pre-filled with existing serial numbers.
I need to look up the user's serial number they provide on the registration form and see if it already exists in the serial table.
What I want to do is see if their serial number is listed in the serial key table. If it is, then they can proceed with registering. If
it is not in the serial key table, then I want to stop the registration and send them to a web page where they can purchase a serial key.
I have the code that does this, but it seems I cannot place it in the 'before registration' event. If I do, I get a php error when I
attempt to login.
Where do I put this code fragment so it will work?
Here is the fragment (pretty standard and right out of the 'if record exists' option):
//********** Check if specific record exists ************
global $conn;
$strSQLExists = "select * from table_keys where steamkey='" . $values["steamkey"] . "'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
// if record exists do something
$message = "Steam Key " . $values["steamkey"] . " already exists."
return true;
}
else
{
// if dont exist do something else
return false;
}
First, is this even the right code to do what I am asking? I need to take what the user types in the field 'steamkey' and then compare it to all the keys in the table
called 'table_keys'. If the key is in there, proceed with registering. If it is not found, then they obviously did not buy a key and need to do so.
If the code above does NOT do this (my php coding is sooooooo bad), could anyone help me so that it DOES do what I need or at least point me in the correct
direction.
Thanks for anyone's help.
Mike