- Home /
Login - var compare to database?
Hey all I've made a very simple login system, and have a registration screen which saves the required data to a Microsoft access database.
What I'm struggling/curious about is how to compare what the user inputs to what exists in the database
Here is my current login code (at the moment I just have a var that can be defined in the code for the users name & surname):
var mySkin : GUISkin;
var GeneralWidth = 73; // Width for most bottons should be the same. Use GeneralWidth. Use there custom Width if needed.
var LoaderHeight = 10;
var LoaderWidth = 10;
var LogHeight = 101;
var LogWidth = 163;
var PlayerUsername = "Test1"; //var for user name
var PlayerPassword = "12345"; //var for user password
var UserHeight = 35;
var UserWidth = 1;
var PassHeight = 65;
var PassWidth = 1;
var GameOwner = ""; //shows current user input for name
var GameOwnerPassword = ""; //shows current user input for password
var UsernameCORRECT = false;
var PasswordCORRECT = false;
function Update (){
// Updates each frames and checks if the TextArea is equal to the username we want
if (PlayerUsername == GameOwner){
UsernameCORRECT = true;
}
else {
UsernameCORRECT = false;
}
// Updates each frames and checks if the TextArea is equal to the password we want
if (PlayerPassword == GameOwnerPassword){
PasswordCORRECT = true;
}
else {
PasswordCORRECT = false;
}
}
function OnGUI () {
// Assign a skin to you menu
GUI.skin = mySkin;
// Background box
GUI.Box (Rect (LoaderHeight,LoaderWidth,220,120), "Log-in");
//Text area for the username
PlayerUsername = GUI.TextArea (Rect(GeneralWidth,UserHeight,100,20),PlayerUsername);
//Text area for the password
PlayerPassword = GUI.TextArea (Rect(GeneralWidth,PassHeight,100,20),PlayerPassword);
// Loads level (0) - customize in build settings
if (GUI.Button (Rect (LogWidth,LogHeight,60,25), "Log-In")) {
if(UsernameCORRECT == true){
if(PasswordCORRECT == true){
Application.LoadLevel (2);
}
}
}
else
{
Debug.Log("Username or Password was Incorrect");
}
}
Comment
Your answer