课后作业1
一、源代码
1.jsp文件代码;
<%@ page contentType = "text/html; charset=utf-8" import = "java.sql.*" errorPage = "error.jsp" %>
<html>
<head>
</head>
<body>
<div style=text-align:center>
<%
String num = request.getParameter("num");
session.setAttribute("username",num);
String userpassword = request.getParameter("userpassword");
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test","root","123");
Statement stmt = connect.createStatement();
String sql = "select * from user where name='"+num+"'and userpassword='"+userpassword+"'";
ResultSet i = stmt.executeQuery(sql);
if(i.next())
{
response.setHeader("refresh","1;url = index1.html");
}
else
{
out.println("<script language = 'javaScript'> alert('密码错误,请重新输入用户名!');</script>");
response.setHeader("refresh","1;url = login.html");
}
stmt.close();
connect.close();
%>
</div>
</body>
<html>
2.html代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户登录</title>
<style type="text/css">
body,td,th {
color: #000;
}
body {
background-color: #0CF;
background-image: url(699069.jpg);
}
#form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {
font-size: 18px;
}
#form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {
font-size: 9px;
}
#form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {
font-size: larger;
}
#form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {
font-size: xx-large;
}
#form1 blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote blockquote p strong {
font-size: x-large;
}
</style>
</head>
<body>
<p><label></label> </p>
<form id="form1" name="form1" method="post" action="">
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<p align="center"><strong>用户登录</strong></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</form>
<p> </p>
<form action="judge.jsp" method="post">
<table width="252" border="1" align="center">
<tr>
<td width="72"><strong>用户名:</strong></td>
<td width="164"><input name="num" type="text" /></td>
</tr>
<tr>
<td><strong>密码:</strong></td>
<td><input name="userpassword" type="password" /></td>
</tr>
<tr>
<td> </td>
<td><a href="judge.jsp" onclick="link"><input type="submit" name="submit" value=" 登录 " ></a></td>
</tr>
</table>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>success</title>
<style type="text/css">
strong {
font-size: x-large;
}
body,td,th {
color: #000;
}
body {
background-color: #0CF;
background-image: url(a.jpg);
}
</style>
</head>
<body>
<div align="center">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p class="a"><em><strong>登录成功!!! </strong></em></p>
</div>
</body>
</html>
二、截图
三、课上未完成原因
当时自己链接数据库和配置上有很大问题,当时自己还是不知道到底改怎么写,导致自己课上无法完成。
四、这门课的目标
这学期这门课自己还是打算好好学,毕竟这对自己有很大的帮助
自己计划每个星期8个小时,平均每天1个小时左右