CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  其他数据库开发 >  VFP

谁有登录验证的源代码?

楼主QQ29(we)2003-12-01 12:35:27 在 其他数据库开发 / VFP 提问

有密码表,但是form   的load事件,不太明白 问题点数:0、回复次数:5Top

1 楼QQ29(we)回复于 2003-12-01 12:41:23 得分 0

如果不用sql语句该怎样写,输入任何字符都可以进入  
  Top

2 楼lai796(ast796)回复于 2003-12-01 12:45:13 得分 0

set   talk   off  
  set   sysmenu   off  
  set   cent   on  
  _screen.windowstate=2  
  _screen.icon="happy.ico"  
  _screen.maxbutton=0  
  _screen.minbutton=1  
  _screen.closable=.f.  
  _screen.picture="photo6.jpg"  
  MODIFY   WINDOW   SCREEN   TITLE   "   聊城大学勤工助学管理系统                                             今天是:"+dtoc(date())+"     "+cdow(date())  
  ZOOM   WINDOW   SCREEN   MAX    
  do   about.mpr  
  open   database   勤工助学数据库.dbc  
  do   form   登录  
  read   even  
  quit  
    2.系统登陆表单的代码:  
        ①命令按钮“登陆”的程序代码:  
  use   pas  
  go   top  
  if   thisform.user.value="qgzx"   and   thisform.pass.value=pas  
  use  
  do   form   主窗体.scx  
  thisform.release  
  else  
  #define   missmatch_loc   "用户或口令错,请重新登录!"  
  wait   window   missmatch_loc   timeout   1  
  thisform.user.value=''  
  thisform.pass.value=''  
  thisform.user.setfocus  
  numcount=numcount+1  
          if   numcount=4  
            mess   =messagebox("三次口令错,将退出程序!",4+16+2,"退出")  
                    clear   event  
          release   thisform  
          endif  
    endif  
  set   talk   off  
  set   sysmenu   off  
  set   cent   on  
  _screen.windowstate=2  
  _screen.icon="happy.ico"  
  _screen.maxbutton=0  
  _screen.minbutton=1  
  _screen.closable=.f.  
  _screen.picture="photo6.jpg"  
  MODIFY   WINDOW   SCREEN   TITLE   "   聊城大学勤工助学管理系统                                             今天是:"+dtoc(date())+"     "+cdow(date())  
  ZOOM   WINDOW   SCREEN   MAX    
  do   about.mpr  
  open   database   勤工助学数据库.dbc  
  do   form   登录  
  read   even  
  quit  
    2.系统登陆表单的代码:  
        ①命令按钮“登陆”的程序代码:  
  use   pas  
  go   top  
  if   thisform.user.value="qgzx"   and   thisform.pass.value=pas  
  use  
  do   form   主窗体.scx  
  thisform.release  
  else  
  #define   missmatch_loc   "用户或口令错,请重新登录!"  
  wait   window   missmatch_loc   timeout   1  
  thisform.user.value=''  
  thisform.pass.value=''  
  thisform.user.setfocus  
  numcount=numcount+1  
          if   numcount=4  
            mess   =messagebox("三次口令错,将退出程序!",4+16+2,"退出")  
                    clear   event  
          release   thisform  
          endif  
    endif  
  Top

3 楼newfang(传说中的MIC)回复于 2003-12-01 12:52:11 得分 0

select   passworddbf  
  locate   allt(username)==allt(thisform.EditUserName.text)  
  if   eof()   then  
  messagebox('无此用户','')  
  retu  
  endif  
  if   not   (allt(userpass)==allt(thisform.EditUserPass.text))   then  
  messagebox('口令错误','')  
  return  
  endif  
  messaebox('登陆成功’,'')Top

4 楼vtebjeeq(问楚)回复于 2003-12-01 19:20:06 得分 0

你到www.sciencep.com去下载个源程序来看看吧Top

5 楼magnetmoon(天涯明月刀)回复于 2003-12-02 08:27:56 得分 0

1.init()  
  #Include   "Api.h"  
   
  Local   mTimeOut  
  ThisForm.DialogInit()  
   
  && Get   default   server,   default   user   from   Registry  
   
  mHKey=0  
  Temp=0  
  If   RegCreateKeyEx(HKEY_CURRENT_USER,"Software\W&Y\W&Y2000\SQL   Server",0,Chr(0),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,@mHKey,@Temp)<>0  
  Return  
  EndIf  
  m_Server=Space(255)  
  mName="Default   Server"  
  L=255  
  If   RegQueryValueEx(mHKey,@mName,0,REG_SZ,@m_Server,@L)<>0  
  m_Server=""  
  Else  
  m_Server=Left(m_Server,L-1)  
  ThisForm.txtServer.Value=m_Server  
  EndIf  
  L=255  
  m_UserID=Space(255)  
  mName="Default   User"  
  If   RegQueryValueEx(mHKey,@mName,0,REG_SZ,@m_UserID,@L)<>0  
  m_UserID=""  
  Else  
  m_UserID=Left(m_UserID,L-1)  
  ThisForm.txtUserID.Value=m_UserID  
  EndIf  
  L=255  
  mTimeOut=Space(255)  
  mName="Connection   TimeOut"  
  If   RegQueryValueEx(mHKey,@mName,0,REG_SZ,@mTimeOut,@L)<>0  
  mTimeOut="1000"  
  Else  
  mTimeOut=Left(mTimeOut,L-1)  
  EndIf  
  ThisForm.ConnectionTimeOut=Val(mTimeOut)  
   
  RegCloseKey(mHKey)  
  ThisForm.txtPwd.SetFocus()  
  Return  
   
  2.cmdOk.click()  
  #Include   "Api.h"  
  #Include   "System.h"  
  #Include   "StringID.h"  
  && Delete   old   DSN   used   in   system  
  If   IsDSN(SYS_DSN)  
  DeleteDSN(SYS_DSN)  
  EndIf  
  If   ISDSN(DB_DSN)  
  DeleteDSN(DB_DSN)  
  EndIf  
  && Create   new   DSN   for   base   data   access  
  If   Not   CreateDSN(SYS_DSN,AllTrim(ThisForm.txtServer.Value),SYS_BASEDB)  
  ThisForm.RetVal=0  
  MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  Release   ThisForm  
  Return  
  EndIf  
   
  Local   m_SysPassword  
  If   ThisForm.chkSystem.Value   =   1  
  m_SystemType   =   "Test"  
  m_SysPassword   =   "wyadminpassword"  
  Else  
  m_SystemType   =   "Erp"  
  m_SysPassword   =   "NothingCouldMakeMeTurnBack"  
  EndIf  
   
  && Open   system   database  
  mAppPath=GetAppPath()+"\Data\SysData"  
  Open   Database   &mAppPath  
  Delete   Connection   SYSCON  
   
  Create   Connection   SYSCON   DataSource   'W&Y2000'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000  
   
  Public   m_CnSys &&   Connection   handle   for   base   data  
  Public   m_CnDB &&   Connection   handle   for   company   data  
  Public   m_UserLevel &&   User   right   level  
  Public   m_CompanyID &&   Company   ID  
  && Connect   to   base   data   server  
  m_CnSys=SQLConnect("SYSCON","wyadmin",m_SysPassword)  
  If   m_CnSys<=0  
  ThisForm.RetVal=0  
  MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  ThisForm.txtServer.Value=""  
  ThisForm.txtServer.SetFocus()  
  Return  
  EndIf  
  =SQLSetProp(m_CnSys,"QueryTimeOut",ThisForm.ConnectionTimeOut)  
  && Switch   to   system   database  
  mSQLRes=SQLExec(m_CnSys,"Use   "+SYS_BASEDB)  
  If   mSQLRes<0  
  ThisForm.RetVal=0  
  MessageBox(GetString(ERR_NO_SYS_DATA),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  ThisForm.txtServer.Value=""  
  ThisForm.txtServer.SetFocus()  
  Return  
  EndIf  
  && Generate   a   unique   ID   for   temp   table  
  mCursor=GenUID()  
  && Query   user   information  
  mSQLRes=SQLExec(m_CnSys,"Select   usr_yhdh,usr_yhmm,usr_yhdj,usr_zbdm,cmp_sjkmc,cmp_fwqmc,usr_gsdm   from   usr_mstr,cmp_mstr     ;  
  where   usr_gsdm=cmp_gsdm   and   usr_yhdh=?ThisForm.txtUserID.Value",mCursor)  
  && Distinguish   the   user   is   leggal  
  If   mSQLRes<=0  
  ThisForm.RetVal=0  
  MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  ThisForm.txtPwd.Value=""  
  ThisForm.txtPwd.SetFocus()  
  Use   In   &mCursor  
  Return  
  EndIf  
  If   RecCount(mCursor)<=0  
  ThisForm.RetVal=0  
  MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  ThisForm.txtPwd.Value=""  
  ThisForm.txtPwd.SetFocus()  
  Use   In   &mCursor  
  Return  
  EndIf  
  && Distinguish   that   password   is   OK  
   
  *!* If   Not   ThisForm.ComparePwd(AllTrim(ThisForm.txtPwd.Value),AllTrim(usr_yhmm))  
  *!* ThisForm.RetVal=0  
  *!* MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  *!* ThisForm.txtPwd.Value=""  
  *!* ThisForm.txtPwd.SetFocus()  
  *!* Use   In   &mCursor  
  *!* Return  
  *!* EndIf  
   
   
  && Create   new   DSN   for   company   data   access  
   
  Public   m_Database,m_ServerData,m_CnDB20,m_CnDB30,m_CnDB31,m_CnDB80,m_CnDBlog  
  m_Database=cmp_sjkmc  
  m_ServerData=cmp_fwqmc  
  If   Not   CreateDSN(DB_DSN,AllTrim(cmp_fwqmc),AllTrim(cmp_sjkmc))  
  ThisForm.RetVal=0  
  Use   In   &mCursor  
  MessageBox(GetString(ERR_CANNOT_CONNECT),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  Release   ThisForm  
  Release   m_CnSys  
  Return  
  EndIf  
   
   
  &&   Login   success,   save   default   server,default   user   in   Registry  
   
  mHKey=0  
  Temp=0  
  If   RegCreateKeyEx(HKEY_CURRENT_USER,"Software\W&Y\W&Y2000\SQL   Server",0,Chr(0),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,0,@mHKey,@Temp)=0  
  mVal=AllTrim(ThisForm.txtServer.Value)  
  RegSetValueEx(mHKey,"Default   Server",0,REG_SZ,@mVal,Len(mVal))  
  mVal=AllTrim(ThisForm.txtUserID.Value)  
  RegSetValueEx(mHKey,"Default   User",0,REG_SZ,@mVal,Len(mVal))  
  RegCloseKey(mHKey)  
  EndIf  
   
  && Switch   to   user   company   server   and   database  
  Delete   Connection   DBCON  
  Delete   Connection   DBCONSYS  
  Delete   Connection   DBCON20  
  Delete   Connection   DBCON30  
  Delete   Connection   DBCON31  
  Delete   Connection   DBCON80  
  Delete   Connection   DBCONlog  
   
   
  Create   Connection   DBCON   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword  
  Create   Connection   DBCONSYS   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000  
  Create   Connection   DBCON20   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000_20  
  Create   Connection   DBCON30   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000_30  
  Create   Connection   DBCON31   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000_31  
  Create   Connection   DBCON80   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000_80  
  Create   Connection   DBCONlog   DataSource   'W&Y2000DB'   UserID   'wyadmin'   Password   &m_SysPassword   Database   wy2000_log  
   
  m_CnDB=SQLConnect("DBCON","wyadmin",m_SysPassword)  
   
  If   m_CnDB<=0  
  ThisForm.RetVal=0  
  Use   In   &mCursor  
  MessageBox(GetString(ERR_COMP_DATA_NOT_FOUND),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  Release   ThisForm  
  Release   m_CnSys  
  Return  
  EndIf  
   
  =SQLSetProp(m_CnDB,"QueryTimeOut",ThisForm.ConnectionTimeOut)  
   
  mSQLRes=SQLExec(m_CnDB,"Use   "+cmp_sjkmc)  
   
   
  If   Upper(cmp_sjkmc)='WY2000_20'  
  m_CnDB20=m_CnDB  
  m_CnDB30=SQLConnect("DBCON30","wyadmin",m_SysPassword)  
  m_CnDB31=SQLConnect("DBCON31","wyadmin",m_SysPassword)  
  m_CnDB80=SQLConnect("DBCON80","wyadmin",m_SysPassword)  
  Else  
  m_CnDB30=m_CnDB  
  m_CnDB20=SQLConnect("DBCON20","wyadmin",m_SysPassword)  
  m_CnDB31=SQLConnect("DBCON31","wyadmin",m_SysPassword)  
  m_CnDB80=SQLConnect("DBCON80","wyadmin",m_SysPassword)  
  EndIf  
  m_CnDBlog=SQLConnect("DBCONlog","wyadmin",m_SysPassword)  
   
  If   mSQLRes<0  
  ThisForm.RetVal=0  
  Use   In   &mCursor  
  MessageBox(GetString(ERR_COMP_DATA_NOT_FOUND),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  Release   ThisForm  
  Release   m_CnSys  
  Release   m_CnDB  
  Return  
  EndIf  
   
  && OK,   set   the   global   varies,   close   temp   table  
   
  Public   m_User  
  m_User=CreateObject("CUser")  
  m_User.UserID=AllTrim(ThisForm.txtUserID.Value)  
   
  If   Not   m_User.IsUserID  
  ThisForm.RetVal=0  
  Use   In   &mCursor  
  MessageBox("無此用戶",BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  Release   ThisForm  
  Release   m_CnSys  
  Release   m_CnDB  
  Release   m_User  
  Return  
  EndIf  
   
  m_Server=AllTrim(ThisForm.txtServer.Value)  
  m_UserID=AllTrim(ThisForm.txtUserID.Value)  
  m_UserLevel=usr_yhdj  
  m_UserPwd=AllTrim(usr_yhmm)  
  m_CompanyID=AllTrim(usr_gsdm)  
   
   
  Use   In   &mCursor  
   
  mSQLRes=SQLExec(m_CnDB,"Exec   UserLogin   ?m_UserID")  
  If   mSQLRes<0  
  MessageBox(GetString(ERR_LOGIN_FAILED),BTN_OK+ICO_STOP,GetString(MSG_ERROR))  
  ThisForm.RetVal=0  
  Return  
  EndIf  
   
   
  If   m_CompanyID='WY'  
  =SQLExec(m_CnDB30,"Exec   UserLogin   ?m_UserID")  
  Else  
  =SQLExec(m_CnDB20,"Exec   UserLogin   ?m_UserID")  
  EndIf  
   
  If   m_SystemType   =   'Test'  
  _Screen.Caption="W&Y2000測試"+"   -   "+GetDescription(m_CompanyID,"CompanyName",m_LangID)+"   ("+m_UserID+")"  
  Else  
  _Screen.Caption="W&Y2000"+"   -   "+GetDescription(m_CompanyID,"CompanyName",m_LangID)+"   ("+m_UserID+")"  
  EndIf  
   
  Local   mFile  
  mFile=LoadDesktop()  
  If   Not   File(mFile)  
  frmDsk.Picture=""  
  Else  
  frmDsk.Picture=mFile  
  EndIf  
   
  ThisForm.RetVal=1  
   
  Release   ThisForm  
  Return  
   
  Top

相关问题

  • 十万火急!求登录验证和对数据库的基本操作源代码!~
  • 急!谁有用户登录的VB.NET源代码呀!
  • 急求windows帐户登录SQL SERVER源代码
  • 高分求够用户身份验证的框架和源代码!
  • 谁有TFTP源代码,而且要求有安全验证的功能
  • VB源代码登陆的时候能否设置一个密码验证的?
  • 谁有四色问题的验证程序?最好有源代码。
  • 源代码!源代码!
  • 求源代码
  • iis源代码!!!!

关键词

  • server
  • thisform
  • mtimeout
  • mhkey
  • mname
  • elsem
  • dsn
  • screen
  • regqueryvalueex
  • 登录

得分解答快速导航

  • 帖主:QQ29

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo