实现验证用户名是否存在、若不存在插入数据库
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<%@ include file="conn.jsp"%>
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 18px;
font-family: "华文行楷";
}
-->
</style>
</head>
<%
String name=(String)request.getParameter("name");
String pass=(String)request.getParameter("password");
String qrpass=(String)request.getParameter("qrpass");
String admin_name="";
Statement sts=conn.createStatement();
String sql1="select username from admin";
ResultSet rst=sts.executeQuery(sql1);
while(rst.next()){
admin_name=rst.getString(1);
if(name.equals(admin_name))
{
%>
<p> </p>
<p> </p>
<p> </p>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#00CC99">
<tr>
<td height="30" bgcolor="#00CC99"> </td>
</tr>
<tr>
<td height="35">
<div align="center">该用户名已存在,请重新输入,<a href="reg.jsp">点此跳转回注册页面</a></div></td>
</tr>
</table>
<%
}
else{
String sql="insert into admin values('"+name+"','"+pass+"')";
int rs=st.executeUpdate(sql);
if(rs!=0){
out.println("注册成功");
}
else{
out.println("注册失败");
}
}
}
%>
</html>
想实现验证用户名是否存在、若不存在插入数据库、,以上代码有何问题、我找不出来啊
<%@ include file="conn.jsp"%>
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {
font-size: 18px;
font-family: "华文行楷";
}
-->
</style>
</head>
<%
String name=(String)request.getParameter("name");
String pass=(String)request.getParameter("password");
String qrpass=(String)request.getParameter("qrpass");
String admin_name="";
Statement sts=conn.createStatement();
String sql1="select username from admin";
ResultSet rst=sts.executeQuery(sql1);
while(rst.next()){
admin_name=rst.getString(1);
if(name.equals(admin_name))
{
%>
<p> </p>
<p> </p>
<p> </p>
<table width="500" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#00CC99">
<tr>
<td height="30" bgcolor="#00CC99"> </td>
</tr>
<tr>
<td height="35">
<div align="center">该用户名已存在,请重新输入,<a href="reg.jsp">点此跳转回注册页面</a></div></td>
</tr>
</table>
<%
}
else{
String sql="insert into admin values('"+name+"','"+pass+"')";
int rs=st.executeUpdate(sql);
if(rs!=0){
out.println("注册成功");
}
else{
out.println("注册失败");
}
}
}
%>
</html>
想实现验证用户名是否存在、若不存在插入数据库、,以上代码有何问题、我找不出来啊
...全文
相关推荐
检查用户名是否已在mysql中存在的php写法
检查用户名是否已在mysql中存在的方法有很多,下面为大家介绍下使用php是如何做到的
SQLite 本地数据库登陆、注册、验证
建立本地数据库SQLite,并进行登陆、注册、验证等操作。
JSP操作数据库,实现新用户注册和用户登录功能
使用JSP操作数据库,实现新用户注册和用户登录功能: 1、新用户注册:新用户填写注册表单,包括用户姓名、密码等信息;如果输入用户名已被注册过,程序提示用户更改自己的用户名。 2、用户登录:输入用户名和密码,程序对其进行验证,如果输入有误,提示重新输入,输入正确的用户名和密码则显示用户成功登陆。
登陆-注册实现代码jsp+jdbc
jsp+jdbc+sql登陆-注册实现代码
PHP中使用crypt()实现用户身份验证
本文介绍了开发PHP应用中如果不想自己开发新的加密算法,还可以利用PHP提供的crypt()函数来完成单向加密功能。实现了一个简单的用户身份验证系统。在使用crypt()保护重要的机密信息时,需要注意的是,在缺省状态下使用crypt()并不是最安全的,只能用在对安全性要求较低的系统中。


Web 开发
