PDA

View Full Version : Userid not generated automatically


TECK
02-22-2004, 12:49 AM
Hi guys,
I'm trying to mod VB3 in a different way, I don't want to generate automatically an userid... instead I want to give the choice to the user to select his(her) userid.
Why? Is really simple, I want to replace the userid with an alphanumeric serial of numbers (employee number).
So, if I work for a company, I will have my unique employee number as userid, for example A50021, my username and my password.

Now, what type will become the "userid" field?
Changing the actual php code should be really easy, to let the user enter his(her) id:
print_input_row('<b>User ID</b>', 'userid', '');
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "user
(userid, username, ...
VALUES
('" . intval($_POST['userid']) . "', '" . addslashes($_POST['username']) . "', ...

$userid = intval($_POST['userid']);
I tried the code above and if I look in the USER table, it defaults still the userid 1, instead of the alphanumeric value.
Let me know what I should change in the table... Thanks guys.

Scott MacVicar
02-22-2004, 12:53 AM
Hi guys,
I'm trying to mod VB3 in a different way, I don't want to generate automatically an userid... instead I want to give the choice to the user to select his(her) userid.
Why? Is really simple, I want to replace the userid with an alphanumeric serial of numbers (employee number).
So, if I work for a company, I will have my unique employee number as userid, for example A50021, my username and my password.

Now, what type will become the "userid" field?
Changing the actual php code should be really easy, to let the user enter his(her) id:
print_input_row('<b>User ID</b>', 'userid', '');
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "user
(userid, username, ...
VALUES
('" . intval($_POST['userid']) . "', '" . addslashes($_POST['username']) . "', ...

$userid = intval($_POST['userid']);
I tried the code above and if I look in the USER table, it defaults still the userid 1, instead of the alphanumeric value.
Let me know what I should change in the table... Thanks guys.
Its probably the intval thats doing it.

Personally I'd add another column like EmployeeID and reference it where appropriate rather than attempt to modify the userid since there are intvals done everywhere to sanatize the data.

TECK
02-22-2004, 02:40 AM
Thanks Scott, is a good idea.
I will post here the results, once I test more in this direction...
What type of field should I use for alphanumeric chars? The text one?

Natch
02-22-2004, 03:50 AM
I would suggest VARCHAR(length.of.Employeeid) ...

TECK
02-22-2004, 10:19 PM
Thanks guys. ;)