检查登录

checklogin.jsp:检查会员登陆信息实现跳转

<%@ page language="java" contentType="text/html; charset=utf-8"

    pageEncoding="utf-8"%>

   <%@page import="java.sql.*,java.io.*,java.lang.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>检查登陆</title>

</head>

<body>

<%

request.setCharacterEncoding("utf-8");

if(request.getParameter("memberName")!=null)

session.setAttribute("b1",request.getParameter("memberName"));

  %>

<%

String m=request.getParameter("memberName");

String p=request.getParameter("password");

String r=request.getParameter("r1");

String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

 String USER = "sa";

 String PASSWORD = "123456";

 String URL = "jdbc:sqlserver://localhost:1433;databaseName=book";

Class.forName(DRIVER);

Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);

 Statement stmt=conn.createStatement();

String sql="SELECT * FROM member where memberName='"+m+"'and password='"+p+"' and level= '"+r+"'";

ResultSet rs=stmt.executeQuery(sql);

if(rs.next()&& r.equals("u"))

{  %>

<jsp:forward page="main.jsp">

<jsp:param value="<%=m %>" name="mn"/>

</jsp:forward>

<% } else if(rs.next()&& r.equals("a")) {

%>

<jsp:forward page="Ahome.jsp"/>

 <% } else{%>

 <jsp:forward page="login.jsp"/>

<% } %>

 </body>

</html>

如果信息不正确跳回登录页面login.jsp

如果用户登录信息正确,跳转到好书网首页main.jsp

 

代码

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>网上书店</title>

<%

request.setCharacterEncoding("utf-8");

if(request.getParameter("c1")!=null)

session.setAttribute("s1",request.getParameter("c1"));

 

 %>

 

<%

String m=request.getParameter("mn");

out.print("你好,"+m+"欢迎你访问好书网");

 %>

<style type="text/css">

#apDiv2 {position:absolute;width:1300px;height:79px;z-index:1;left: 15px;top: 120px;

}

#apDiv1 {position:absolute;width:1376px;height:954px;z-index:1;left: 31px;top: 30px;

}

#apDiv3 {position:absolute;width:117px;height:523px;z-index:2;left: 25px;top: 197px;

}

#apDiv4 {position:absolute;width:830px;height:120px;z-index:3;left: 167px;top: 131px;

}

#apDiv5 {position:absolute;width:872px;height:115px;z-index:4;left: 166px;top: 278px;

}

#apDiv6 {position:absolutewidth:240pxheight:184px;z-index:5;left: 1080px;top: 219px;

}

#apDiv7 {position:absolute;width:240px;height:328px;z-index:6left: 1092px;top: 325px;

}

#apDiv8 {position:absolute;width:491px;height:342px;z-index:7;left: 179px;top: 218px;

}

#apDiv9 {position:absolute;width:200px;height:115px;z-index:1;left: 21px;top: 29px;

}

#apDiv10 {position:absolute;width:1303px;height:99px;z-index:1;left: -20px;top: -120px;

}

#apDiv11 {position:absolute;width:1300px;height:79px;z-index:1;left: 10px;top: 18px;

}

#apDiv12 {position:absolute;width:200px;height:75px;z-index:2;left: 1108px;top: -48px;

}

 </style>

</head>

 <body>

<div id="apDiv12">  </div>

<div id="apDiv1">

  <div id="apDiv2">

    <table width="101%" border="0" bordercolor="#FF6600">

      <tr>

        <th width="17%" height="51" bgcolor="#00FF99" scope="col"><h2><em><strong>好书网</strong></em></h2></th>

        <th width="14%" bordercolor="#F0F0F0" bgcolor="#00FF99" scope="col"><h3 class="STYLE2"><a href="main.jsp">首页</a></h3></th>

        <th width="14%" bgcolor="#00FF99" scope="col"><span class="STYLE2"><a href="recently.jsp">最近新书</a></span></th>

        <th width="13%" bgcolor="#00FF99" scope="col"><span class="STYLE4"><a href="shopping.jsp" >购物车</a></span></th>

        <th width="13%" bgcolor="#00FF99" scope="col"><span class="STYLE4"><a href="login.jsp">登录注册</a></span></th>

        <th width="29%" bgcolor="#00FF99" scope="col"><form id="form1" name="form1" method="post" action="">

          <label>

            <input type="text" name="textfield" />

            搜索

          </label>

        </form>

        </th>

      </tr>

    </table>

    <div id="apDiv10"><img src="C:\Users\Administrator\Desktop\image\3.jpg" width="1366" height="112" />

  </div>

  </div>

  <div id="apDiv3">

    <p>全部分类</p>

    <p><a href="classify.jsp?id=1">计算机</a></p>

    <p><a href="classify.jsp?id=2">物理</a></p>

    <p><a href="classify.jsp?id=3">数学</a></p>

    <p> <a href="classify.jsp?id=4">小说</a></p>

    <p><a href="classify.jsp?id=5">童话</a></p>

    <p><a href="classify.jsp?id=6">化学</a></p>

    <p><a href="classify.jsp?id=7">文学</a></p>

    <p><a href="classify.jsp?id=8">科技</a></p>

    <p><a href="classify.jsp?id=9">综合</a></p>

    <p><a href="classify.jsp?id=0">其他</a></p>

     

    <p><a href="person.jsp?id=<%=m%> ">个人账户</a></p>

    <p><a href="help.jsp">我的帮帮</a></p>

    <p> </p>

  </div>

  <div id="apDiv8">

    <div id="apDiv9">

    <%

 String name;

String intro;

String image;

int inven;

int se;

 String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

 String USER = "sa";

 String PASSWORD = "123456";

 String URL = "jdbc:sqlserver://localhost:1433;databaseName=book";

 Class.forName(DRIVER);

  Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);

 Statement stmt=conn.createStatement();

String sql="SELECT * FROM bookinfo";

ResultSet rs=stmt.executeQuery(sql);

while(rs.next())

{

name=rs.getString(2);

intro=rs.getString(3);

inven=rs.getInt(4);

image=rs.getString(5);

se=rs.getInt(7);

 %>

    <form action="main.jsp" method="post">

     <p><img src="<%=image %>" width="102" height="97" alt="<%=name %>" /></p>

     <p><input type="checkbox" name="c1" value="<%=name%>" ><%=name%> </p>

     <p>售价:<%=se%></p>

     <p>简介:<%=intro %></p>

     <p>库存:<%=inven %></p>

     <p>

       <input type="submit" name="add" id="add" value="加入购物车" />

       <input type="submit" name="buy" id="buy" value="立即购买" />

     </p>

     </form>

    <%} %>

   </div>

  </div>

</div>

</body>

</html>

 

转载于:https://www.cnblogs.com/gjzf/p/5603263.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值