Classic ASP VBScript: Creating an E-mail verification link with a random code.

DWMX
MS Access
WIN XP PRO
Classic ASP VBScript

Hello.  Could someone, please, assist me with an E-mail verificattion link?  I have the page that sends an E-mail confirmation to the user after they complete the "Register" form.  I would like, however, to include a verification link with a random code appended to it, but I'm not sure how to do that.

Thanks so much,
Shane

lshaneAsked:
Who is Participating?
 
bugs021997Commented:
@lshane

Its strange that no one has replied to you but don't worry....

All you got to do is....

When a user registers before inserting call a RANDOM number generation code which would generate a random number against that user and insert that along with the registration details in table. have one more column named active('Y/N') in the table. So in all you will have two tables getting added verificationCode and active..... now before sending email to the User, certainly which happens after the data is inserted in table....email the user the verification code to be entered on one of the pages u already have created to verify....

The link would look like http://yourHost/something/verifyUser.asp?code=FGDFHFTRYVREYRE65754

Specify the Verification Code in the mail as well as give the user the complete link on which he can click and be verified....


Now on your end have a page called as verifyUser which will have two textbox as a inputs and will crosscheck the verification against the username... its just simple select statement that you need to fire.....

I will paste the RANDOM Code Generation Script here now....


<%
     Function gen_pass(max_num)

     dim gen_array(62)
' ------- Setup array of characters to chose from ------
   
     gen_array(0) = "0"
     gen_array(1) = "1"
     gen_array(2) = "2"
     gen_array(3) = "3"
     gen_array(4) = "4"
     gen_array(5) = "5"
     gen_array(6) = "6"
     gen_array(7) = "7"
     gen_array(8) = "8"
     gen_array(9) = "9"
     gen_array(10) = "A"
     gen_array(11) = "B"
     gen_array(12) = "C"
     gen_array(13) = "D"
     gen_array(14) = "E"
     gen_array(15) = "F"
     gen_array(16) = "G"
     gen_array(17) = "H"
     gen_array(18) = "I"
     gen_array(19) = "J"
     gen_array(20) = "K"
     gen_array(21) = "L"
     gen_array(22) = "M"
     gen_array(23) = "N"
     gen_array(24) = "O"
     gen_array(25) = "P"
     gen_array(26) = "Q"
     gen_array(27) = "R"
     gen_array(28) = "S"
     gen_array(29) = "T"
     gen_array(30) = "U"
     gen_array(31) = "V"
     gen_array(32) = "W"
     gen_array(33) = "X"
     gen_array(34) = "Y"
     gen_array(35) = "Z"
     gen_array(36) = "a"
     gen_array(37) = "b"
     gen_array(38) = "c"
     gen_array(39) = "d"
     gen_array(40) = "e"
     gen_array(41) = "f"
     gen_array(42) = "g"
     gen_array(43) = "h"
     gen_array(44) = "i"
     gen_array(45) = "j"
     gen_array(46) = "k"
     gen_array(47) = "l"
     gen_array(48) = "m"
     gen_array(49) = "n"
     gen_array(50) = "o"
     gen_array(51) = "p"
     gen_array(52) = "q"
     gen_array(53) = "r"
     gen_array(54) = "s"
     gen_array(55) = "t"
     gen_array(56) = "u"
     gen_array(57) = "v"
     gen_array(58) = "w"
     gen_array(59) = "x"
     gen_array(60) = "y"
     gen_array(61) = "z"

     Randomize
' ------- Generate the string until the length of max_num is met ------
     do while len(output) < max_num
          num = gen_array(Int((61 - 0 + 1) * Rnd + 0))
          output = output + num
     loop

' ------- Let function result = output ------

     gen_pass = output
     End Function

' ------- Outside Function:Get max_num Value from page form ------

       NUMGEN = "20"
       intGEN = CInt(NUMGEN)
       response.write "<pre>"&intGEN &" CHARACTER PASSWORD GENERATED = " & gen_pass(intGEN) & "</pre>" & vbcrlf
     end if  
         
%>




Hope this helps you,


Cheers
^_^
BUGS
0
 
lshaneAuthor Commented:
Would someone, please, be kind enough to let me know why I am no longer receiving responses?  If I have errored in some way, I would like the opportunity to make that right, please.

Thanks so much,
Shane
0
 
bugs021997Commented:
@Ishane,

Here is another link for random character generation

http://4guysfromrolla.com/webtech/tips/t060500-1.shtml


Hope you got the steps as to what needs to done....


1. USER FILLS THE REGISTRATION FORM SUBMITS THE DETAILS....

2. RANDOM CODE GENERATION TAKES PLACE FOR THAT USER, You can generate that when the user has submitted the form or you can generate it when the user calls register.asp and store it in a variable which can be passed to the DATABASE when the user submits the registration details.

3. You Insert all the registration details along with verification code and active set as N by default.

4. You email the user with the verification code generated as it would be stored in a variable or a textbox so you need not fetch the database table again.

5. User receives the email and sees the verification code....goes to the http://yourHost/something/verifyUser.asp and enters the verification code.

6. You verify the code against that user and set the active flag as Y and allow user to login.


Hope this helps you,


Cheers
^_^
BUGS
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
lshaneAuthor Commented:
Hi, BUGS!  Thank you so much.  I will have to give it a try this evening, but I wanted to respond and let you know I appreciate your reply.

I'm a little shaky on the placement, etc., but I will work through it this evening and let you know.

Thanks so much,
Shane
0
 
bugs021997Commented:
@lshane

Not an issue, try and lemme know....buzz me if you need some help....
0
 
lshaneAuthor Commented:
Hi, bugs.  OK, I was attempting to give this a try, but I am not sure where to place the code.  I also would like assistance with how to actually append the code to a link after the user submits the form.  Here is the code for the E-mail sent to the user when they submit the form.  I placed it within the DW Insert Behavior:

'************************************************************************
'BEGIN EMAIL SCRIPT TO SEND LOGIN DETAILS TO E-MAIL FROM REGISTER PAGE
Set objMessage = Server.CreateObject("CDO.Message")
objMessage.Subject = "Thank You For Registering"
objMessage.From = """WEB SUPPORT SYSTEM"" <support@macweb.org>"
objMessage.To = Request.Form("custEmail")
objMessage.TextBody = "Name: " & Request.Form("custFirst") & " " & Request.Form("custLast") & vbCrlf & "Username: " & Request.Form("custUsername") & vbCrlf & "Password: " & Request.Form("custPassword") & vbCrlf & vbCrlf
objMessage.Send
'END EMAIL SCRIPT TO SEND LOGIN DETAILS TO E-MAIL FROM REGISTER PAGE
'************************************************************************


Thanks, bugs!

Shane
0
 
lshaneAuthor Commented:
Hey, bugs.  Are you there?
0
 
bugs021997Commented:
@lshane

Apologies for replying late, did not realise you had  posted a comment until you posted to checkback today...

Anyways you need to place the code just after the registration process is complete and you have entered all the data into the database. Hope you got it...

Say for example on page1.asp, you got your registration form....

User fills all the data on page1.asp and submits the page to page2.asp

On page2.asp you first do create a connection string, connect to database, create a recordset create an insert statement and insert all the data from the user form.... just wen you have completed inserting the records into the database, paste the email, so the email is send as well and then redirect the user to a thankyou page
0
 
lshaneAuthor Commented:
Hi, bugs.  No problem at all - thank you.  OK, I think I can manage the "E-mail send" portion now, but where do I place the "Function" code that you pasted up above?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.