用SQL Server验证用户名和密码,从页面输入的用户名和密码与数据库的用户名和密码进行匹配,正确则登入,错误则提醒。

  1. <form action="index.jsp" method="post" >
  2. <!--大的div框架开始-->
  3. <div id="div">
  4.  
  5. <!--左边div框架开始-->
  6. <div id="div1">
  7. <p style="margin-left:30px;"><img src="data:image/login/vjia.gif"></img></p>
  8. <div style="width:350px;height:20px;margin-left:30px;margin-top:-10px">
  9. <p><hr/></p>
  10. </div>
  11. <p style="margin-top:0px;margin-left:30px"><img src="data:image/red_btn.gif"></img></p>
  12. <p style="margin-top:-35px;margin-left:40px;color:#fff;font-size:12px;align:center">Vjia用户</p>
  13.  
  14. <p style="margin-top:-28px;margin-left:110px"><img src="data:image/btn_long.gif"></img></p>
  15. <p style="margin-top:-35px;margin-left:120px;font-size:12px">Vancl用户</p>
  16.  
  17. <div style="width:350px;height:20px;margin-left:30px;margin-top:-8px">
  18. <p><hr/></p>
  19. </div>
  20.  
  21. <p style="margin-left:60px">用户名:<input type="text" name="userName"></p>
  22. <p style="margin-left:75px">密码:<input type="password" name="password"></p>
  23.  
  24. <p style="margin-left:150px;margin-top:10px"><input type="submit" value="" style="width:65px;height:26px;background:url(image/tu2.gif)"></p>
  25.  
  26. <p style="margin-left:30px;margin-top:30px;margin-right:80px">使用合作伙伴账号登入Vjia:<img src="data:image/account_qq.gif"></img></p>
  27.  
  28. <p style="margin-left:30px;margin-top:0px;color:red;font-weight:bold">温馨提示:</p>
  29.  
  30. <p style="text-indent:3em;font-size:14px">如果还未注册VJIA用户,您可以使用VANCL用户名进行登录,登录后系统会自动为您注册一个与VANCL账户相关联的VJIA账户。账户关联后您可共享VANCL的会员积分和消费金额。</p>
  31. <p style="margin-top:30px;margin-left:100px">有任何疑问请点击<font style="font-weight:bold">帮助中心</font><font style="font-weight:bold">联系客服</font></p>
  32. </div>
  33. </form>
  1. <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
  2. <%@page import="java.sql.Connection"%>
  3. <%@page import="java.sql.PreparedStatement"%>
  4. <%@page import="java.sql.ResultSet"%>
  5. <%@page import="jdbc.sqlServer"%>
  6.  
  7. <%
  8. String userName = request.getParameter("userName");
  9. userName = new String(userName.getBytes("ISO-8859-1"),"utf-8");
  10. String password = request.getParameter("password");
  11.  
  12. //引用连接数据库方法
  13. sqlServer sq=new sqlServer();
  14. //得到数据库连接
  15. Connection con = sq.getConnection();
  16. //编写sql语句
  17. String sql="select * from Admin where userName=? and password=? ";
  18. //得到数据库操作对象
  19. PreparedStatement st=null;
  20. st =con.prepareStatement(sql);
  21. st.setString(1,userName);
  22. st.setString(2,password);
  23.  
  24. //得到结果集
  25. ResultSet rs=null;
  26. rs=st.executeQuery();
  27. if(rs.next()){
  28. session.setAttribute("url",userName);
  29.  
  30. %>
  31. <script type="text/javascript">
  32. alert("登入成功");
  33. location="jieHe.jsp";
  34. </script>
  35. <%
  36.  
  37. }else{
  38. %>
  39. <script type="text/javascript">
  40. alert("请先注册,后登入");
  41. location="doLog.jsp";
  42. </script>
  43. <%
  44.  
  45. }
  46. //释放资源
  47. sq.ShiFang(rs,st,con);
  48.  
  49. %>

用SQL Server验证用户名和密码的更多相关文章

  1. sql server 设置用户名和密码

    安全性:security 登录名:Logins 可以双击直接对里面现有的用户权限进行修改 也可以右击新建新用户 并对新用户权限进行设置

  2. 【转】在SQL Server 2008中SA密码丢失了怎么办?

    sql server 2008的sa用户莫名其妙就登陆不进去了.提示如下: 以上提示就表明是密码错误,但密码我可是记得牢牢的,也许是系统被黑的原因吧.一直以来我的Windows身份验证就用不起,以下方 ...

  3. c# 调用mysql数据库验证用户名和密码

    使用mysql数据库验证用户名和密码时,如果用户名是中文,一直查不到数据 需要把app.config 中修改为 数据库统一设置utf8编码格式,连接数据库的时候设置编码Charset=utf8可以避免 ...

  4. Android 设置代理(验证用户名和密码)

    这几天在研究在Android中,解析网页,但是公司内容,链接外网需要代理,并需要验证用户名和密码,十分头疼,网上查了下,没有头绪,最后总算在一个外国博客中看到类似的,记录下 URL url = new ...

  5. django 使用form验证用户名和密码

    form验证可以减少查询数据库,所以代码先预先验证,有问题可以返回给前端显示 1.在users文件夹下新建forms.py文件,用来验证用户名和密码是否为空,密码长度是否大于6 # -*- codin ...

  6. SQL Server 验证身份证合法性函数(使用VBScript.RegExp)

    原文:SQL Server 验证身份证合法性函数(使用VBScript.RegExp) 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wzy0623 ...

  7. SQL Server 2014忘记SA密码或禁用而且Windows身份验证也无法登录的解决办法

    SQL Server双重验证都无法验证的情况下如何处理 1.以管理员身份运行sql配置管理器 2.打开[Sql Server 服务]节点关掉所有服务 3.双击本地实例[SQL Server (MSSQ ...

  8. Sql Server 2008修改Sa密码

    1.用Windows验证模式进入数据库管理器 右键根目录 >>>>属性>>>>左边的安全性 选择sql server 和windows 验证(SQL S ...

  9. SQL Server 2008 忘记sa密码的解决办法

    由于某些原因,sa和windows验证都不能登录 sql server,可以用独占模式,修改sa密码先在服务管理器停止Sql Server服务,然后打开命令行,进入 SQL Server安装目录,进入 ...

随机推荐

  1. Linux - 用户管理与文件权限

    目录 Linux - 用户管理与文件权限 创建普通用户 切换用户 userdel删除用户 sudo 命令 文件与目录权限 Linux权限的解读 目录权限 查看用户权限的命令 文件权限 修改权限的命令 ...

  2. Git 基础教程 之 搭建Git服务器

    截图自: 廖雪峰老师官方网站 https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0 ...

  3. CODEVS 3500

    题目描述 输入3个数a,b,c,求a^b mod c=?输入描述          三个数a,b,c输出描述         一个数,即a^b mod c 的答案.样例输入5 10 9样例输出 4 基 ...

  4. Java基础——基础数据类型与读入输出

    首先我们写完了HelloWorld就学会了java的一种输出 System.out.println() 用起来就像是被强化过的C++的puts函数 或者就是自带endl的cout函数,中间的" ...

  5. 剖析Spark-Shell

    打开spark-shell,我们可以看到 function main() { if $cygwin; then stty -icanon min 1 -echo > /dev/null 2> ...

  6. 一次MySQL(INNODB存储引擎) 死锁捉虫记

    前言 任何系统不管在什么阶段都需要关注生产环境错误日志,最近几个月内,发现偶尔会出现数据库死锁情况.以前碰到的数据库类错误大部分是SQL语法造成的错误,来到新东家之后才第一次碰到死锁情况,以前是搞游戏 ...

  7. array_change_key_case()

    定义和用法 array_change_key_case() 函数将指定数组的所有的键进行大小写转换. 如果数组的键(索引)为数字则不发生变化.如果未提供第二个参数,则默认转换为小写. 语法 array ...

  8. android studio配置android开发环境

    1.下载安装android-studio-bundle 地址:https://developer.android.com/sdk/index.html 注意:指定android sdk和android ...

  9. LeetCode——Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  10. 成都传智播客java就业班激情洋溢的青春篮球赛

    为了缓解学员们的学习压力,也为了培养学员们的团队协作精神,5月28日下午,在班主任倪老师和王老师联手带领下,我们1406280ls" style="color:rgb(51,102 ...