免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1709 | 回复: 3
打印 上一主题 下一主题

[函数] 一个验证用户口令与密码的函数调用问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-06-26 22:46 |只看该作者 |倒序浏览
我在用application buider编用户界面,我现在设计了一个登陆界面。要求用在数据库中的人员编号与口令登录。我用的数据库是oracle,编程语言是c。存储数据的数据库是user_table。ticket.pc文件里面的原函数是:
char *get_password(int user_num1)
EXEC SQL BEGIN DECALRE SECTION;
char user_password_out[8];
short user_password_out_ind; /*指示符变量 */
char user_name_host[8];
EXEC SQL END DECALRE SECTION;
EXEC SQL declare password_cursor for
select user_name,user_password from user_table
where user_num= :user_num1;
EXEC SQL open password_cursor;
EXEC SQL fetch password_cursor into :user_name_host,:user_password_out:user_password_out_ind; /* 如果用户存在就返回用户口令 */
if (user_password_out_ind==0)
return (user_password_out);
else return(NULL);
EXEC SQL close password_cursor;
}
在主函数在application builder 的stubs.c里面:
char  *user_num_text=(char *)NULL;
char  *user_password_text=(char *)NULL;
int temp_num,temp_password;
char text[8];
/*从界面的控件上面取数*/
temp_num=XmTextFieldGetString(dtb_das1_mainwindow.user_num)
temp_password=XmTextFieldGetString(dtb_das1_mainwindow.user_password)
spritf(&user_password_text,"%d",temp_password);
memcpy(text,get_password(temp_num),;
printf("text0=%s",text);
/*用户不存在 */
if (text ==NULL)
{ printf("not find the user\n";
printf("text1=%s\n",text)
}
/*密码错误*/
if(text != user_password_text)
{
  printf("password wrong\n";
  printf("text2=%s\n",text);
}
/*通过验证*/
if(text==user_password_text)
  {
   printf("success\n";
   printf("text3=%s\n",text);
}
这样写text的返回值可以吗》?

论坛徽章:
0
2 [报告]
发表于 2003-06-27 09:21 |只看该作者

一个验证用户口令与密码的函数调用问题

if(text != user_password_text)
{
printf("password wrong\n";
printf("text2=%s\n",text);
}
/*通过验证*/
if(text==user_password_text)
{
printf("success\n";
printf("text3=%s\n",text);
}


?????
text 是字符串,能直接比较吗?

论坛徽章:
0
3 [报告]
发表于 2003-06-27 09:40 |只看该作者

一个验证用户口令与密码的函数调用问题

对于你使用的密码验证部分,请使用字符串比较函数 strcmp() 来执行即可。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
4 [报告]
发表于 2003-06-27 12:33 |只看该作者

一个验证用户口令与密码的函数调用问题

楼主妹妹:
看到我留言后按照签名档中的地址给我发信。
我这周比较忙,可能要到下周周二以后才有空。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP