为什么不会返回错误的提示框,比如用户名为空的

tongxin9377 tongxin9377 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
为什么不会返回错误的提示框,比如用户名为空的应该返回一个提示框才对呀,帮忙
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!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=gb2312">
<meta http-equiv="refresh" content="3;url=denglu.jsp">
<title>无标题文档</title>
<%
request.setCharacterEncoding("gb2312");
String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Tomcat4\\webapps\\ROOT\\web1\\web\\db1.mdb";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
//ResultSet rs=st;
String errmsg="错误!";
boolean founderr=false;
String name=errmsg;
String userpassword=errmsg;
String reuserpassword=errmsg;

if(request.getParameter("name").equals("")){
errmsg=errmsg+"用户名不能为空,";
founderr=true;
}else name=request.getParameter("name");

if(request.getParameter("userpassword").equals("")){
errmsg=errmsg+"密码不能为空,";
founderr=true;
}else userpassword=request.getParameter("userpassword");

if(request.getParameter("reuserpassword").equals("")){
errmsg=errmsg+"密码确认不能为空,";
founderr=true;
}else reuserpassword=request.getParameter("reuserpassword");

if(!userpassword.equals(reuserpassword)){
errmsg=errmsg+"两次密码不同!";
founderr=true;
}
String funtion=request.getParameter("funtion");
String partment=request.getParameter("partment");


String sql="select * from user where name='"+name+"'";
ResultSet rs=st.executeQuery(sql);
if(rs.next()){
errmsg=errmsg+"用户名已被别人注册";
founderr=true;
}
else

if(founderr==false) {
String sql1="insert into user(name,password,partment,funtion)values('"+name+"','"+userpassword+"','"+partment+"','"+funtion+"')";
st.executeUpdate(sql1);
}
st.close();
con.close();
%>
</head>
<body>
<!--<jsp:forward page="denglu.jsp">
</jsp:forward> -->
</body>
</html>
...全文

相关推荐

JavaScript判断用户名和密码不能为空的实现代码

下面小编就为大家带来一篇JavaScript判断用户名和密码不能为空的实现代码。小编觉得挺不错的,现在分享给大家,也给大家做个参考,一起跟随小编过来看看吧

weixin_38638647

判断用户注册用户时用户名是否重名

private void button2_Click(object sender, EventArgs e) { if (this.textBox1.Text==""||this.textBox1.Text=="请输入用户名:") { MessageBox.Show("用户名不能为空!"); } string uname = this.textBox1.Text; string pwd = this.textBox3.Text; hyqpm.con.Close(); hyqpm.con.Open(); SqlCommand com = new SqlCommand("insert into admin values('"+uname+"','"+pwd+"')",hyqpm.con); if (checkuName(uname)) //判断用户名否存在 { MessageBox.Show( "用户名已存在!请重新输入:"); return; } if (this.textBox1.Text==""||this.textBox2.Text=="") { MessageBox.Show("密码不能为空!"); return; } if (com.ExecuteNonQuery()>0) { MessageBox.Show("提交成功!"); } hyqpm.con.Close(); } // 判断用户名是否存在 private bool checkuName(string name) { bool flag = false; SqlCommand com1 = new SqlCommand("select * from admin where loginid='" + this.textBox1.Text + "'", hyqpm.con); SqlDataReader dr1 = com1.ExecuteReader(); if (dr1.Read()) { flag = true; } dr1.Close(); return flag; }

hyqpm

js判断登陆用户名及密码是否为空的简单实例

js判断登陆用户名及密码是否为空的简单实例 [removed] // 验证输入不为空的脚本代码 function checkForm(form) { if(form.username.value == ) { alert&#40;用户名不能为空!&#41;; form.username.focus(); return false; } if(form.password.value == ) { alert&#40;密码不能为空!&#41;; form.password.focus(); return false; } return true; } &lt;/script

weixin_38716081

基于ajax后台返回的数据为空前台显示出现undefined的解决方法

今天小编就为大家分享一篇基于ajax后台返回的数据为空前台显示出现undefined的解决方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

weixin_38645373

mybatis中查询结果为空时不同返回类型对应返回值问题

主要介绍了mybatis中查询结果为空时不同返回类型对应返回值问题,本文分几种方法给大家介绍的非常详细,需要的朋友可以参考下

weixin_38722052
评论 9
收藏 已收藏
分享
返回顶部
tongxin9377
Web 开发 81,107 成员 341,720 内容