Jump to content

WHMCS license add-on with C#


zahlio

Recommended Posts

So I'm developing software in c#, and I use WHMCS as my license provider. So is there anyway of making c# check if the license is valid?

 

I have made a form with a text box (where users will input there license key from WHMCS), and I now need it to check if it is valid.

 

If it is, the program will give a msg.box and if it is not valid, it will give another msg.box

 

Can someone help?

 

This is currently the code I have:

 

public bool TryCn(string KeyNr, string KeyActive)

{

// check sql data base

MySqlConnection con = new MySqlConnection("server=localhost;user=username;password=password;database=keys;");

MySqlCommand cmd = new MySqlCommand("SELECT * FROM user_keys WHERE user_key = '" + KeyNr + "' AND user_active ='" + KeyActive + "';");

cmd.Connection = con;

 

con.Open();

 

MySqlDataReader reader = cmd.ExecuteReader();

if (reader.Read() != false)

{

 

if (reader.IsDBNull(0) == true)

{

cmd.Connection.Close();

reader.Dispose();

cmd.Dispose();

return false;

 

}

else

{

cmd.Connection.Close();

reader.Dispose();

cmd.Dispose();

return true;

 

}

}

else

{

return false;

}

 

}

 

private void login_Click(object sender, EventArgs e)

{

if (TryCn(KeyBox.Text, ActiveBox.Text) == true)

{

VersionCheck form_launch = new VersionCheck();

form_launch.ShowDialog();

this.Close();

}

else

{

string KeyNr = KeyBox.Text;

string KeyActive = ActiveBox.Text;

MessageBox.Show("Your key (" + KeyNr + ") was invalid or not active. \nPlease check if it is the correct key or you need to buy another month.", "WarZ Hack - Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

 

private void AboutLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

{

AboutForm form_about = new AboutForm();

form_about.ShowDialog();

}

 

private void LoginForm_Load(object sender, EventArgs e)

{

 

}

 

private void KeyBox_TextChanged(object sender, EventArgs e)

{

 

}

 

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated