主题:简单的登陆
<%@page contentType="text/html;charset=gb2312"%>
<%@page import="java.sql.*"%>
<%
String Name="";
String No="";
String Pwd="";
String Msg="";
if(request.getParameter("No")!=null)
{
Name=request.getParameter("Name");
No=request.getParameter("No");
Pwd=request.getParameter("Pwd");
String SQL="select * from modifycourse";
SQL=SQL+" Where Number='"+No+"' And Name='"+Name+"'And Pwd='"+Pwd+"'";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}
try{
conn=DriverManager.getConnection("jdbc:odbc:select");
stmt=conn.createStatement();
rs=stmt.executeQuery(SQL);
}
catch(SQLException e){
System.out.println(e.getMessage());
}
if(!rs.next())
{
Msg="输入错误";
}
else
{
//response.sendRedirect("choose.jsp");
Msg="输入正确";
}
}
%>
<html>
<body>
<CENTER>
<H1>欢迎登陆学生选课系统</H1><HR>
<FORM ACTION="login.jsp" METHOD="POST">
<P>姓名:<input type="text" NAME="Name" VALUE="<%=Name%>"></P>
<P>学号:<input type="text" NAME="No" value="<%=No%>"></P>
<P>密码:<input type="password" NAME="Pwd"></P>
<p><input type="submit" value="提交">
<input type="reset" value="重置">
</FORM>
<HR>
<%=Msg%>;
</CENTER>
</body>
</html>
错那了??
<%@page import="java.sql.*"%>
<%
String Name="";
String No="";
String Pwd="";
String Msg="";
if(request.getParameter("No")!=null)
{
Name=request.getParameter("Name");
No=request.getParameter("No");
Pwd=request.getParameter("Pwd");
String SQL="select * from modifycourse";
SQL=SQL+" Where Number='"+No+"' And Name='"+Name+"'And Pwd='"+Pwd+"'";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException ce){
out.println(ce.getMessage());
}
try{
conn=DriverManager.getConnection("jdbc:odbc:select");
stmt=conn.createStatement();
rs=stmt.executeQuery(SQL);
}
catch(SQLException e){
System.out.println(e.getMessage());
}
if(!rs.next())
{
Msg="输入错误";
}
else
{
//response.sendRedirect("choose.jsp");
Msg="输入正确";
}
}
%>
<html>
<body>
<CENTER>
<H1>欢迎登陆学生选课系统</H1><HR>
<FORM ACTION="login.jsp" METHOD="POST">
<P>姓名:<input type="text" NAME="Name" VALUE="<%=Name%>"></P>
<P>学号:<input type="text" NAME="No" value="<%=No%>"></P>
<P>密码:<input type="password" NAME="Pwd"></P>
<p><input type="submit" value="提交">
<input type="reset" value="重置">
</FORM>
<HR>
<%=Msg%>;
</CENTER>
</body>
</html>
错那了??