zahlio Posted October 24, 2012 Share Posted October 24, 2012 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) { } } 0 Quote Link to comment Share on other sites More sharing options...
JFOC Posted October 26, 2012 Share Posted October 26, 2012 WebRep currentVote noRating noWeight You can use socket and combined with WHMCS API 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.