MySQL based on Linux by C

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;
}

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值