Call this from main:
Code:
 

string query;
string username;
string password;

function userlogin(){

if(!mySQL_IsConnected()&&!mySQL_Connectdb("dbname","localhost","dbuser","dbpass")){
beep;exit;
}


inkey(username);
inkey(password);

str_cat(query, "select * from users WHERE username='");
str_cat(query, username);
str_cat(query, "' AND password='");
str_cat(query, password);
str_cat(query, "';");

if(mySQL_ExecQuery(query)&&mySQL_RowNumber()==1){
loggedinok=true;
}else{
exit;//if no entry, exit
}


//now you can gather info from the db

mySQL_Closedb();
}


This is a quick code I trew togheter, but you will see the main principles. Of course you may alter the code that exits if there is no such account, maybe show an error and let the user try again.