%
Set databaseConnection = getDatabaseConnection()
formFields = Array("hon_use_name", "hon_use_email", "hon_use_password", "confirmPassword")
errorMessage = ""
userID = CStr(Request.Cookies("hon")("hon_use_id"))
If userID = "" Then
// this should rarely happen, if the user comes straight to this page
Response.Redirect("http://www.jjjwebdevelopment.com/306sites/hackornot/default.asp")
End If
// set up a dictionary for form info
Set formInfo = CreateObject("Scripting.Dictionary")
// set defaults if just entering the form
For Each fieldName In formFields
fieldValue = ""
formInfo.Add fieldName, fieldValue
Next
// if the user has submitted the form
If Request("command") = "Register" Then
// get form info
For Each fieldName In formFields
fieldValue = CStr(Request.Form(fieldName))
formInfo.Item(fieldName) = fieldValue
Next
// validate required fields
errorMessage = ternaryOperator((formInfo.Item("hon_use_name") = ""), errorMessage & "Please provide your name.
", errorMessage)
errorMessage = ternaryOperator((formInfo.Item("hon_use_email") = ""), errorMessage & "Please provide your email address.
", errorMessage)
errorMessage = ternaryOperator((formInfo.Item("hon_use_password") <> formInfo.Item("confirmPassword") Or formInfo.Item("hon_use_password") = ""), errorMessage & "Please be sure your password and confirm password entries match and are not blank.
", errorMessage)
// also be sure you are not using an email already taken
Set checkEmailRS = createRecordSet("SELECT TOP 1 hon_use_id FROM hon_use_users WHERE hon_use_email = '" & safeDBEncode(formInfo.Item("hon_use_email")) & "'", databaseConnection)
If Not checkEmailRS.EOF Then
errorMessage = errorMessage & "The email address '" & formInfo.Item("hon_use_email") & "' is already in use.
If you mistyped your address, please correct the form and resubmit.
If you've forgotten your password you may have it emailed to you."
End If
destroyRecordSet(checkEmailRS)
// if they entered "Anonymous" for their name, correct it so we do not have problems
If formInfo.Item("hon_use_name") = "Anonymous" Then
formInfo.Item("hon_use_name") = "Anonymous User"
End If
If errorMessage = "" Then
// first get the user name currently associated with this id
Set getUserRS = createRecordSet("SELECT TOP 1 hon_use_name FROM hon_use_users WHERE hon_use_id = " & safeDBEncode(userID), databaseConnection)
If getUserRS.EOF Then
errorMessage = errorMessage & "The HACK or NOT database experienced a transient problem. Please try your request again."
Else
If CStr(getUserRS.Fields("hon_use_name")) = "Anonymous" Then
// if anonymous, then update this record to be the person now registering
Call executeSQL("UPDATE hon_use_users SET hon_use_name = '" & safeDBEncode(formInfo.Item("hon_use_name")) & "', hon_use_email = '" & safeDBEncode(formInfo.Item("hon_use_email")) & "', hon_use_password = '" & safeDBEncode(formInfo.Item("hon_use_password")) & "' WHERE hon_use_id = " & safeDBEncode(userID), databaseConnection)
Else
// if not, then leave that record alone, and create a new user
Call executeSQL("INSERT INTO hon_use_users (hon_use_name, hon_use_email, hon_use_password) VALUES ('" & safeDBEncode(formInfo.Item("hon_use_name")) & "', '" & safeDBEncode(formInfo.Item("hon_use_email")) & "', '" & safeDBEncode(formInfo.Item("hon_use_password")) & "')", databaseConnection)
// and make sure they are logged in
Set getNewUserIDRS = createRecordSet("SELECT TOP 1 hon_use_id FROM hon_use_users WHERE hon_use_email = '" & safeDBEncode(formInfo.Item("hon_use_email")) & "' ORDER BY hon_use_id DESC", databaseConnection)
If Not getNewUserIDRS.EOF Then
userID = getNewUserIDRS.Fields("hon_use_id")
Response.Cookies("hon")("hon_use_id") = CStr(userID)
Response.Cookies("hon").Expires = "11/7/2030"
Else
errorMessage = errorMessage & "The HACK or NOT database experienced a transient problem. Please try your request again."
End If
destroyRecordSet(getNewUserIDRS)
End If
// now set the success session and send to success page
Session("success") = "signup"
Response.Redirect("success.asp")
End If
destroyRecordSet(getUserRS)
End If
End If
destroyConnection(databaseConnection)
%>
HACK or NOT Registration |
|
To submit your writing to HACK or NOT, you must first register with the site. This is only necessary so we can keep track of which submissions are yours and let you check your scores later. We will not sell your information to anyone, ever. If you have already registered with HACK or NOT, please log in. <% If errorMessage <> "" Then %> <%= errorMessage %> <% End If %> |
<%= getRightBarAd() %> |