Here's something to start with. To get the first four characters of the user's name, use the LEFT function. Assuming you have a text box on the form called 'txtName':
<cfset username = LEFT(form.txtName, 4) />
If the name entered in that field was 'mkwebnovice', this would give you 'mkwe'. Next, you can use the MAX function in SQL (provided you are using SQL) to get the highest ID record in your user's table. I am of course assuming that you have a users table with an auto incrementing id field. When you do your insert statement, use this function and combine it with the result of the LEFT function above.
<cfquery datasource="whatever your datasource is" name="qryGetMaxUserID">
DECLARE @userID varchar(10);
SELECT @userID = CAST((SELECT MAX(userID) + 1 AS newUserID FROM users) AS varchar(10));
INSERT
users
(
username
)
VALUES
(
'#username#' + @userID
)
</cfquery>
If you a user table and the last userID is 20, this will result in a username of 'mkwe21'.
I hope this helps.
Reputation Points: 23
Solved Threads: 10
Junior Poster in Training
Offline 79 posts
since Feb 2008