% Option Explicit %> <% '**************************************************************************************** '** Copyright Notice '** '** Web Wiz Guide - Web Wiz Forums '** '** Copyright 2001-2002 Bruce Corkhill All Rights Reserved. '** '** This program is free software; you can modify (at your own risk) any part of it '** under the terms of the License that accompanies this software and use it both '** privately and commercially. '** '** All copyright notices must remain in tacked in the scripts and the '** outputted HTML. '** '** You may use parts of this program in your own private work, but you may NOT '** redistribute, repackage, or sell the whole or any part of this program even '** if it is modified or reverse engineered in whole or in part without express '** permission from the author. '** '** You may not pass the whole or any part of this application off as your own work. '** '** All links to Web Wiz Guide and powered by logo's must remain unchanged and in place '** and must remain visible when the pages are viewed unless permission is first granted '** by the copyright holder. '** '** This program is distributed in the hope that it will be useful, '** but WITHOUT ANY WARRANTY; without even the implied warranty of '** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER '** WARRANTIES WHETHER EXPRESSED OR IMPLIED. '** '** You should have received a copy of the License along with this program; '** if not, write to:- Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom. '** '** '** No official support is available for this program but you may post support questions at: - '** http://www.webwizguide.info/forum '** '** Support questions are NOT answered by e-mail ever! '** '** For correspondence or non support questions contact: - '** info@webwizguide.com '** '** or at: - '** '** Web Wiz Guide, PO Box 4982, Bournemouth, BH8 8XP, United Kingdom '** '**************************************************************************************** 'Set the response buffer to true Response.Buffer = True 'Dimension variables Dim rsCheckUsername 'Recorset holding all the username in the database Dim rsAdminUpdate 'Recordset holding the updated admin username and password Dim rsAdminDetails 'recordset holding the admin details Dim strMode 'holds the mode of the page, set to true if changes are to be made to the database Dim strNewUsername 'Holds the new username Dim strNewPassword 'Holds the new password Dim blnUsernameOK 'Set to ture if the username is not already in the database Dim strCheckUsername 'Holds the username from the database that we are checking against 'Initialise variables blnUsernameOK = True 'Read in the users details from the form strNewUsername = Request.Form("name2") strNewPassword = Request.Form("password2") strMode = Request.Form("mode") 'Intialise the ADO recordset object Set rsAdminDetails = Server.CreateObject("ADODB.Recordset") 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblAuthor.Username, tblAuthor.Password " strSQL = strSQL & "From tblAuthor " strSQL = strSQL & "WHERE tblAuthor.Author_ID=1;" 'Query the database rsAdminDetails.Open strSQL, strCon 'Read in the username from the datbase If NOT rsAdminDetails.EOF Then 'Read in the Username and password from the recordset strUsername = rsAdminDetails("Username") strPassword = rsAdminDetails("Password") End If 'Clean up rsAdminDetails.Close Set rsAdminDetails = Nothing 'If the user is changing there username and password then update the database If strMode = "change" Then 'Intialise the ADO recordset object Set rsCheckUsername = Server.CreateObject("ADODB.Recordset") 'Read in the usernames from the database to check the username does not alreday exsist 'Initalise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblAuthor.Username FROM tblAuthor WHERE tblAuthor.Username = '" & strNewUsername & "';" 'Query the database rsCheckUsername.Open strSQL, strCon 'If there a record returned then the username is already in use If NOT rsCheckUsername.EOF Then blnUsernameOK = False 'Make sure the user has not entered disallowed usernames If InStr(1, strNewUsername, "password", vbTextCompare) Then blnUsernameOK = False If InStr(1, strNewUsername, "author", vbTextCompare) Then blnUsernameOK = False If InStr(1, strNewUsername, "code", vbTextCompare) Then blnUsernameOK = False If InStr(1, strNewUsername, "username", vbTextCompare) Then blnUsernameOK = False If InStr(1, strNewUsername, "N0act", vbTextCompare) Then blnUsernameOK = False 'If the new username is the same as the old username then the username is OK If strNewUsername = strUsername Then blnUsernameOK = True 'Clean up rsCheckUsername.Close Set rsCheckUsername = Nothing 'If the Username dose not already exsists then save the users details to the database If blnUsernameOK = True Then 'Intialise the ADO recordset object Set rsAdminUpdate = Server.CreateObject("ADODB.Recordset") 'Intialise the strSQL variable with an SQL string to open a record set for the Author table strSQL = "SELECT tblAuthor.Username, tblAuthor.Password, tblAuthor.User_code " strSQL = strSQL & "From tblAuthor " strSQL = strSQL & "WHERE tblAuthor.Author_ID=1;" 'Set the Lock Type for the records so that the record set is only locked when it is updated rsAdminUpdate.LockType = 3 'Set the Cursor Type to dynamic rsAdminUpdate.CursorType = 2 'Open the author table rsAdminUpdate.Open strSQL, strCon 'Randomise the system timer Randomize Timer 'Calculate a code for the user strUserCode = strNewUsername & (987656342 * CInt((RND * 32000) + 100)) & Left(strNewPassword,1) & Right(strNewPassword,1) 'Update the recordset rsAdminUpdate.Fields("Username") = strNewUsername rsAdminUpdate.Fields("Password") = strNewPassword rsAdminUpdate.Fields("User_code") = strUserCode 'Update the database with the new user's details rsAdminUpdate.Update 'Re-run the NewUser query to read in the updated recordset from the database rsAdminUpdate.Requery 'Write a cookie with the User ID number so the user logged in throughout the forum 'Write the cookie with the name Forum containing the value UserID number Response.Cookies("Forum")("UserID") = strUserCode strUsername = rsAdminUpdate("Username") strPassword = rsAdminUpdate("Password") 'Clean up rsAdminUpdate.Close Set rsAdminUpdate = Nothing End If End If 'Reset Server Objects Set adoCon = Nothing Set strCon = Nothing %>
| Sorry the Username you requested is already taken. Please choose another Username. |