MySQL based on Linux by C

Source: Internet
Author: User
Tags mysql strcmp linux
Mysql
int Loginjudge (User_account req)
{

int i=0;
Char *name;
Char *reqname;
Char *password;
Char *reqpass;
Reqname=req. Name;
Reqpass=req. Password;

if (!) ( Mysql_connect (&mysql,null, "root", "1111"))
return FALSE;
if (mysql_select_db (&mysql, "Serverdb"))
return FALSE;
if (mysql_query (&mysql, select Name,password from Main))
return FALSE;
if (!) ( Res=mysql_store_result (&mysql))
return FALSE;
while ((Row=mysql_fetch_row (res))
{
NAME=ROW[0];
PASSWORD=ROW[1];
if (!strcmp (name,reqname))
{
if (!strcmp (Password,reqpass))
return TRUE;
Else
return FALSE;
}
}
if (! mysql_eof (RES))
return FALSE;
Mysql_free_result (RES);
Mysql_close (&mysql);
return FALSE;
}

int authority (char *name)
{
Long Ibackvalue;
Char *cdbname;
Char *cdbauthority;
Char *cquename;
Char *cvalueone;
Char *cvaluetwo;

Cquename=name;
Cvalueone= "1";
cvaluetwo= "2";
if (!) ( Mysql_connect (&mysql,null, "root", "1111"))
return FALSE;
if (mysql_select_db (&mysql, "Serverdb"))
return FALSE;
if (mysql_query (&mysql, select name,authority from Main))
return FALSE;
if (!) ( Res=mysql_store_result (&mysql))
return FALSE;
while ((Row=mysql_fetch_row (res))
{
CDBNAME=ROW[0];
CDBAUTHORITY=ROW[1];
if (!strcmp (cdbname,cquename))
{
if (!strcmp (cvalueone,cdbauthority))
{
ibackvalue=1;
if (!strcmp (cvaluetwo,cdbauthority))
ibackvalue=2;
}
Else
ibackvalue=3;


}
}

if (! mysql_eof (RES))
return FALSE;
Mysql_free_result (RES);
Mysql_close (&mysql);
return ibackvalue;
}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.