⑴ 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();
}
} 有不理解的可以追問我~希望能幫助你