Registration - Tutorial + Project Download

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
11 posts Page 1 of 2
Contributors
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 445
Joined: Tue Feb 16, 2010 6:24 am

*Make Sure that the user has no @gmail.com on it*
For Example :
i have a email at gmail - austinlivengood@gmail.com now what you do is you take the @gmail.com off
and the text that would be entered would just be austinlivengood

------------------------------------------------------------------------------------------------------------------------

ok well i am going to be showing you how to make a registration for your program, this has nothing to do with mysql and things. This is using a smtp. Its going to generate a key code for the use and most of the program will not be workable with out registration.
For Example :
Image

Main Form
Now for this the form load is, this code will check and see if the program has been registered
Code: Select all
If My.Settings.key = "" Then
Button2.Enabled = False
Else
If My.Settings.inkey = My.Settings.key Then
Button2.Enabled = True
Else
Button2.Enabled = False
End If
End If
Button 1 click: *Opens this registration form*
Code: Select all
Register.ShowDialog()
Button 2 click: *After Registration*
Code: Select all
NextForm.Show()
Me.Close()
Registration Form :
This is one of the most important forms to the program, because this will save the settings of the key code.
Image

ok so now one form load we its going to generate a random key code

Imports :
Code: Select all
Imports System.Net.Mail
Code: Select all
    Private Sub Register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Random()
        If My.Settings.inkey = "" Then
        Else
            MsgBox("You have already registered!", MsgBoxStyle.Exclamation, Title:="Information")
            Me.Close()
        End If
        If My.Settings.key = "" Then
            Random()
            My.Settings.key = Label1.Text
            My.Settings.Save()
        End If
    End Sub
    Public Sub Random()
        If My.Settings.key = "" Then
        Else
            Dim Z As New Random
            Label1.Text = Z.Next(100000, 999999999)
        End If
    End Sub
this code will generate a key code and if you have already registered then it will open a message box saying so.

For Button 1 : i would like to give thanks to CodeNStuff for his wounderful coding on his email sender, i have used part of it to send out the email with the keycode. Thanks CodeNStuff cooll;

Button1 Click :
Code: Select all
        Dim username As String
        Dim password As String
        username = Convert.ToString(My.Settings.uname)
        password = Convert.ToString(My.Settings.pass)
        Dim from As New MailAddress(My.Settings.from)
        Dim [to] As New MailAddress(Me.TextBox3.Text)
        Dim theMailMessage As New MailMessage(from, [to])
        theMailMessage.Body = "Your Key is : " + My.Settings.key
        theMailMessage.Subject = "Registration Key Code"
        Dim theClient As New SmtpClient(My.Settings.server)
        theClient.UseDefaultCredentials = False
        Dim theCredential As New System.Net.NetworkCredential(username, password)
        theClient.Credentials = theCredential
        theClient.EnableSsl = True
        Try
            theClient.Send(theMailMessage)
        Catch wex As Net.WebException
        End Try
        MsgBox("Keycode Sent!", MsgBoxStyle.Exclamation, Title:="Information")
Button 2 Click :
this will check and see if the key code is correct or not.
Code: Select all
If TextBox2.Text = My.Settings.key Then
            My.Settings.inkey = TextBox2.Text
            My.Settings.Save()
            MsgBox("Sucess!", MsgBoxStyle.Information, Title:="Registered")
            Form1.Button2.Enabled = True
            Me.Close()
        Else
            MsgBox("Wrong Key Code", MsgBoxStyle.Exclamation, Title:="Error")
        End If

Settings :

Theses are the settings need in the project
Image

Project Download :
Registration - Tutorial.zip
Last edited by Livengood on Thu Mar 11, 2010 5:07 am, edited 1 time in total.
Image
User avatar
alex6848
VIP - Donator
VIP - Donator
Posts: 201
Joined: Sat Jan 16, 2010 10:26 pm

it doesn't work because email now reqiers ssl
Free Facebook Page Likes - http://fbliker.tk/?ref=gillis
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 445
Joined: Tue Feb 16, 2010 6:24 am

did you make sure that your username didnt have @gmail.com?

For example :
i have a email at gmail - austinlivengood@gmail.com now what you do is you take the @gmail.com off
and the text that would be entered would just be austinlivengood
Image
User avatar
MiztaInsane
VIP - Donator
VIP - Donator
Posts: 13
Joined: Thu Jan 14, 2010 3:39 pm

You most add this since you have ssl enable
Code: Select all
theClient.Port = 587
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 445
Joined: Tue Feb 16, 2010 6:24 am

it still sends without a port
Image
User avatar
alex6848
VIP - Donator
VIP - Donator
Posts: 201
Joined: Sat Jan 16, 2010 10:26 pm

dosn't work :(
Free Facebook Page Likes - http://fbliker.tk/?ref=gillis
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Changed the code a little bit and it worked :)
Image
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

alex6848 wrote:
it doesn't work because email now reqiers ssl
it works for me
You can find me on Facebook or on Skype mihai_92b
User avatar
cvilanova
New Member
New Member
Posts: 14
Joined: Fri Jun 04, 2010 6:23 am

nice tut, i will use to my project in the university.. you are cool!! cooll;
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hi Livengood
Great Tutorial, and it worked like a dream for me cooll;
all i had to do was change "SSL=TRUE" TO SSL=FALSE and then add my details and Voila!! :)

Nice one

Chris
Image
11 posts Page 1 of 2
Return to “Tutorials”