当前位置:首页 » 网页前端 » web注册页面代码
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

web注册页面代码

发布时间: 2022-05-17 22:01:12

⑴ javascript html 设计一个登录界面

注册页面代码:

<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>注册</title>
</head>
<body>

<formmethod="post"onsubmit="returnfalse"id="form">
<inputtype="text"name="username"placeholder="用户名"><br>
<inputtype="password"name="password"placeholder="密码"><br>
<inputtype="password"name="rePassword"placeholder="再次输入密码"><br>
<inputtype="submit"onclick="register_user()"value="注册"><br>
</form>
<ahref="login.html">去登录</a><script>
varlocalDB=openDatabase('localDB','1.0','TestDB',2*1024*1024);
localDB.transaction(function(ts){
ts.executesql('CREATETABLEIFNOTEXISTSuser(username,password)')
});
functionregister_user(){
varusername=document.getElementsByTagName("input")[0].value;
varpassword=document.getElementsByTagName("input")[1].value;
varrePassword=document.getElementsByTagName("input")[2].value;
if(password!=rePassword)
{
alert("两次输入的密码不同,请重新输入");
}else
{
localDB.transaction(function(ts){
ts.executeSql("INSERTINTOuser(username,password)VALUES('"+username+"','"+password+"');");
alert("注册成功");
});
}
}
</script>
</body>
</html>

登录页面代码:

<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>登录</title>
</head>
<body>
<formonsubmit="returnfalse"method="post">
<inputtype="text"placeholder="用户名"><br>
<inputtype="password"placeholder="密码"><br>
<inputtype="submit"value="登录"onclick="login()"><br>
</form>
<ahref="register.html">去注册</a>
<script>
varlocalDB=openDatabase('localDB','1.0','TestDB',2*1024*1024);
localDB.transaction(function(ts){
ts.executeSql("SELECT*FROMuser",[],function(tx,results){
varlen=results.rows.length;
if(len<=0)
{
localDB.transaction(function(ts){
ts.executeSql('CREATETABLEIFNOTEXISTSuser(username,password)')
});
}
});
});


functionlogin(){
varusername=document.getElementsByTagName("input")[0].value;
varpassword=document.getElementsByTagName("input")[1].value;
localDB.transaction(function(ts){
ts.executeSql("SELECT*FROMuserWHEREusername='"+username+"';",[],function(ts,res){
if(res.rows.length<=0)
{
alert("登录失败,用户未注册");
}elseif(password==res.rows[0].password)
{
alert("登录成功,三秒后跳转到网络");
setInterval(function(){
location.href="https://www..com";
},3000);
}else
{
alert("登录失败,密码错误");
}
});
})
}
</script>
</body>
</html>

以上代码使用了WEB SQL,还请选择合适的浏览器查看。


⑵ 急求用javaWeb做个注册页面的方法

public
void
service(ServletRequest
arg0,
ServletResponse
arg1)
throws
ServletException,
IOException
{
//获得客户端提交的姓名和密码
String
name=arg0.getParameter("name");
String
pwd=arg0.getParameter("pwd");
//调用Dao
RegDao
reg=new
RegDao();
regDao.reg(name,pwd);
}

⑶ 在写一个简单的JavaWeb注册登录页面,jsp+servlet+service++xml+bean来实现。

你是把jsp加载到MyEclipse中打开的吗?你应该是直接打开的吧?
你可以按照我说的方法来写:
1,设计数据库
2. 写javaBean
3.在中写方法和方法的实现
4,完成Servlet
5.写jsp页面
6.在XML中配置
7,启动服务器,运行

⑷ 用java web编写一个用户注册界面(只要写出以下要求就行)

一步步更新:页面
<form action="regist.servlet" method="post"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableAdd borTop"> <tr> <th width="14%" height="30" nowrap>用户名</th> <td class="pl5"> <INPUT id="sName" name="name" type="text" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>密码</th> <td class="pl5"> <INPUT name="password" type="password" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>确认密码</th> <td class="pl5"> <INPUT name="confrimPwd" type="password" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>性别</th> <td class="pl5"> 男<INPUT name="sex" type="radio" value="1" checked="checked" size="20"> 女<INPUT name="sex" type="radio" value="0" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>爱好</th> <td class="pl5"> <INPUT name="enjoy" type="checkbox" size="20" value="篮球">篮球 <INPUT name="enjoy" type="checkbox" size="20" value="足球">足球 </td> </tr> <tr> <th width="14%" height="30" nowrap>生日</th> <td class="pl5"> <INPUT name="brithday" type="text" size="20"> </td> </tr> <tr> <th width="14%" height="30" nowrap>备注</th> <td class="pl5"> <textarea rows="5" cols="200" name="remark"></textarea> </td> </tr> <tr> <th width="14%" height="30" nowrap> </th> <td class="pl5"> <input type="submit" value="提交"> <input type="reset" value="重置"> </td> </tr></table></form>

数据库部分:
import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import com.mysql.jdbc.Connection;import com.mysql.jdbc.Statement;public class DataBaseUtil { public static Connection getConnection() throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://192.168.100.113/datebase", "username", "password"); return conn; } public static Statement getPS() throws ClassNotFoundException, SQLException { Statement statement = (Statement) getConnection().createStatement(); return statement; } public static void close(Connection conn,Statement st,ResultSet rs) throws SQLException{ if(rs != null) { rs.close(); } if(st != null) { st.close(); } if(conn != null) { conn.close(); } }}

⑸ 怎么做一个注册页面并用servlet判断,如果密码,账号都不为空,并且密码和确认密码相等。成功就跳

你的这个问题会让我想问你是不是我同学,因为我刚好也在做这个,中午跟朋友讨论刚好解决了。
思路如下:用form表单接收注册页面输入框的账号和密码并通过web.xml提交到你创建的class中。我在class文件中的代码如下:题主可以参考下(这里强调一下,关于密码和账号为空不要用null去判断,用“”双引号作为判断条件即可!!!)
package com;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Check extends HttpServlet{
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String Name = req.getParameter("Name");//获取用户名
String passw = req.getParameter("passw");//获取密码
if(Name==""||passw==""){//判断用户名和密码是否为空
String str = "你没有输入用户名或密码";
req.setAttribute("Alert", str);
req.getRequestDispatcher("index.jsp").forward(req, resp);
System.out.println("11");
}else{
if(Name.equals(passw)){//用户名、密码一致跳转到另一界面
req.getRequestDispatcher("jsp/a.jsp").forward(req, resp);
}else{//用户名密码不正确,返回到注册界面
String str = "你的输入有误,请重新输入";
req.setAttribute("Alert", str);
req.getRequestDispatcher("index.jsp").forward(req, resp);
}
}
}
}

⑹ WEB程序设计(后台登陆页面和用户注册页面设计)

这个其实蛮简单 也是WEB中最基础的东西

1.就是在SQLSERVER中建立表 来保存用户名和密码之类的信息。
2.信息获取的话 无非就是两个textbox,把密码的那个textbox的“type”属性改为“password”
3.创建数据库链接字符串 然后 sqlconnection --接着编写SQL查询语句--最后--sqlcommand。
4.这里我的方法是 用sqlcommand的Executereader方法来获取一个 datatable "dt".
然后来判断 dt的dt.rows.count属性是否大于0 如果大于0 则证明用户名与密码正确的了。 (即这行记录存在于表中)
前提是 你的SQL语句 必须这么写
select * from "保存用户信息的表" where textbox1.text=username and textbox2.text=password

以上是我自己想的方法 很不专业 但是功能都能实现 忘高手给个比较专业的方法。

⑺ WEB 简单注册页面

<html>
<head>
<script language="Javascript">
function commitCheck() {
if(!checkName()) {
return false;
} else if(!checkPasswor()){
return false;
} else if(!checkMail()){
return false;
} else if(!checkPhone()){
return false;
} else {
// submit
return true;
}
}
function checkName(){
var obj = document.getElementById("n");
var s = obj.value;
s = trim(s);
if(s.length==0){
alert("NAME CAN NOT BE NULL");
obj.focus();
return false;
} else {
return true;
}
}
function checkPasswor(){
var obj = document.getElementById("p");
var obj2 = document.getElementById("r");
var s = obj.value;
var s2 = obj2.value;
if(s.length==0){
alert("PASSWORD CAN NOT BE NULL");
obj.value = "";
obj2.value = "";
obj.focus();
return false;
} else if(s != s2){
alert("INVALID PASSWORD");
obj.value = "";
obj2.value = "";
obj.focus();
return false;
} else {
return true;
}
}
function checkMail(){
var obj = document.getElementById("m");
var s = obj.value;
s = trim(s);
var reg = /^[A-Za-z0-9_\-]+@[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+$/;
if(s.length > 0 && !s.match(reg)){
alert("INVALID MAIL");
obj.focus();
return false;
}else{
return true;
}
}
function checkPhone(){
var obj = document.getElementById("ph");
var s = obj.value;
s = trim(s);
var reg = /^[0-9]*$/;
if( !s.match(reg)){
alert("INVALID PHONE");
obj.focus();
return false;
}
}
function trim(s){
var start = 0;
var end = 0;
var leng = s.length;
var findStart = false;
var index ;
for(index=0; index<leng;index++){
if( s.charAt(index) == ' ' ) {

} else {
if(!findStart){
start = index;
findStart = true;
}
end = index + 1;
}
}
return s.substring(start,end);
}
</script>
</head>
<body>
<form>
<table>
<tr>
<td align="right">NAME</td>
<td align="left"><input id="n" type="text" maxLength="40"/></td>
</tr>
<tr>
<td align="right">PASSWORD</td>
<td align="left"><input id="p" type="password" maxLength="40"/></td>
</tr>
<tr>
<td align="right">CONFIRM</td>
<td align="left"><input id="r" type="password" maxLength="40"/></td>
</tr>
<tr>
<td align="right">MAIL</td>
<td align="left"><input id="m" type="text" maxLength="100"/></td>
</tr>
<tr>
<td align="right">PHONE</td>
<td align="left"><input id="ph" type="text" maxLength="20"/></td>
</tr>
<tr>
<td align="center" colSpan="2"><input type="button" value="commit" onclick="commitCheck()"/></td>
</tr>
</table>
</form>
</body>
</html>

⑻ Java Web开发jsp注册页面怎样用javaScript代码直接在页面上注册内容后面显示验证信息

可以实现的,如果你是要在注册文本框后面显示的话可以增加一个span,然后在javascript中获取到文本框的值,然后传给span,
<form name="f">注册名:<input type="text" name="username" ><span id="s"></span>

<javascrpt代码>
function back(){
var username=document.f.username.value;
document.getElementsbyId("s").innerHTML=username;
}

⑼ 如何在jsp页面上实现点击注册按钮,弹出一个窗体来注册(类似于百度贴吧的登录和注册),求详细代码和注释

jsp中的注册弹出新窗口是通过window.open一个新页面来实现的。
页面register.jsp代码如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="cn.wy.Pet.User" 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=gb2312" />
<title>会员注册例子讲解</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FF0000;
font-weight: bold;
}
.STYLE2 {color: #FF0000}
.STYLE3 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>

<body style="font-size:12px">
<form id="form1" name="form1" method="post" action="<%=actionStr%>reg">
<p align="center"><br />
<span class="STYLE3">用户注册</span></p>
<table width="582" height="302" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#BCACD2">
<tr>
<td width="80" align="right">用户名:</td>
<td width="496" align="left"><input name="userName" type="text" id="userName" size="16" maxlength="16" />
<span class="STYLE1">*</span> 3~16位字母或者数字(如:8hack)</td>
</tr>
<tr>
<td align="right">密码:</td>
<td align="left"><input name="password1" type="text" id="password1" size="16" maxlength="16" />
<span class="STYLE1">* </span> 3~16位字母或者数字(如:abc123)</td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td align="left"><input name="password2" type="text" id="password2" size="16" maxlength="16" />
<span class="STYLE1">*</span> 必须和上面输入的密码相同</td>
</tr>
<tr>
<td align="right">电子邮件:</td>
<td align="left"><input name="email" type="text" id="email" maxlength="20" />
<span class="STYLE1">*</span> 找回密码和联系用(如:[email protected])</td>
</tr>
<tr>
<td align="right">联系电话:</td>
<td align="left"><input name="tel" type="text" id="tel" size="20" maxlength="20" />
如(0871-8888888,13888853113)</td>
</tr>
<tr>
<td align="right">联系地址:</td>
<td align="left"><input name="address" type="text" id="address" maxlength="50" /></td>
</tr>
<td height="40" colspan="2" align="center"><input type="submit" name="Submit" value="确认注册" />
<input type="reset" name="Submit2" value="重新填写" /></td>
</tr>
</table>
</form>
</body>
</html>
后台servlet的处理:
public class reg extends HttpServlet
{
public reg()
{
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
DBConnection dbc=null;
String userName;
String psd;
String email;
String tel;
String address;
int popedom;
response.setContentType("text/html;charset=UTF-8");
out = response.getWriter();
try{
dbc = new DBConnection();
PreparedStatement ps = null;
userName = request.getParameter("userName");
psd = login.encrypt(request.getParameter("password1").toString());
email = request.getParameter("email");
tel = request.getParameter("tel");
address = request.getParameter("address");
popedom = Integer.parseInt(request.getParameter("popedom"));
if (userName != null && psd != null && email != null)
{
ps = dbc.getCon().prepareStatement("insert into [User](UName,Upass,UEmail,UTel,UAddress,UPopedom) values(?,?,?,?,?,?)");
ps.setString(1, userName);
ps.setString(2, psd);
ps.setString(3, email);
ps.setString(4, tel);
ps.setString(5, address);
ps.setInt(6, popedom);
ps.execute();
System.out.print("新用户注册:" + request.getParameter("userName") + " ");
out.print("<script>alert('恭喜您:注册成功!现已经登录到网站!');history.go(-1)</script>");
}
if (dbc != null)
dbc.dbClose();
}
catch(SQLException ex)
{
out.print("<script>alert('注册失败!数据库连接错误!');history.go(-1)</script>");
ex.printStackTrace();
if (dbc != null)
dbc.dbClose();
}
}
}

⑽ 高分请教:HTML用户注册页面代码,用MYSQL数据库

你要先在数据库中创建一个表,这个表就是存用户名和密码的然后再编写网页代码 我用的C# 给你看一下 ,这里只给你功能代码吧public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]);
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
string sql = "select * from [用户权限] where 用户ID='" + TextBox1.Text + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())//判断是否有记录
{
if (dr["用户密码"].ToString() != TextBox2.Text)//判断密码是否一致
{
Page.RegisterClientScriptBlock("alert", "<script>alert('密码不正确')</script>");
} else
{
Session["用户ID"] = TextBox1.Text;
Session["管理员"] = dr["管理员"]; if (Convert.ToBoolean(Session["管理员"]))
//根据用户信息,跳转到相应的页面
Response.Redirect("guanliyuan.aspx");//管理员页面 else Page.Response.Redirect("ptyonghu.aspx");//普通用户页面 }
} else
{
Page.RegisterClientScriptBlock("alert", "<script>alert('用户不存在')</script>");
} conn.Close();
}
} 有不理解的可以追问我~希望能帮助你