導航:首頁 > 編程語言 > 注冊登錄代碼

注冊登錄代碼

發布時間:2023-07-07 02:18:40

java 中 有1.注冊 2.登錄 3.退出功能 我輸入一 就實現注冊然後返回 選擇2就能登錄 提供以下代碼

不要復雜化,代碼要簡單化,需求是什麼就寫什麼。參考如下:

//用於保存用戶帳戶信息的數組
Scannerscanner=newScanner(System.in);
String[]user=newString[2];
while(true){
//銀行主界面
System.out.println("------------------------------歡迎來到銀行------------------------------");
System.out.println("請選擇編號: 1:注冊 2:登錄 3退出");

intnum=scanner.nextInt();
switch(num){
case1:
//注冊
System.out.println("請輸入您的賬戶名:");
Stringname=scanner.next();
user[0]=name;
System.out.println("請輸入您的密碼:");
Stringpassword=scanner.next();
user[1]=password;
System.out.println("注冊成功!");
//返回主界面
break;
case2:
while(true){
//登錄
System.out.println("請輸入您的帳戶名:");
StringuserName=scanner.next();
System.out.println("請輸入您的密碼:");
StringuserPwd=scanner.next();
//判斷輸入的用戶名是否在數組中存在(判斷該用戶是否注冊)
if(user[0].equals(userName)&&user[1].equals(userPwd)){
System.out.println("-----------登錄成功,請選擇您要辦理的業務------------");
break;
}else{
System.out.println("-----------用戶名或密碼錯誤,請重新輸入------------");//返回到登錄界面
continue;
}
}
break;
case3:
//退出系統程序結束
System.out.println("退出成功,歡迎再次使用");
System.exit(0);
break;
default:
break;
}
}

② 注冊/登陸頁面HTML代碼該怎麼寫

以下為個人原創教學例子,任何人引用需註明出自網路知道用戶am7972,樓主可供參考x0dx0a該例子涵蓋了文本框、密碼框、下拉菜單、單選框、復選框及文本區的使用x0dx0a同時在數據的使用方面涵蓋了文本型、數值型、日期型、布爾型的使用x0dx0a也涵蓋了在會員信息入資料庫前,進行嚴格的數據檢查x0dx0a不足處,js驗證還不是太完善,不過有服務端認證足夠了x0dx0a會員仿慧注冊x0dx0ax0dx0ax0dx0ax0dx0a

x0dx0ax0dx0a x0dx0a x0dx0ax0dx0a x0dx0a x0dx0a x0dx0ax0dx0a x0dx0a x0dx0ax0dx0ax0dx0a

會員注員

姓名:
密碼:
性別備姿答:
生日:
年齡:
愛好: 上網 讀書 體育
上網方式: x0dx0a x0dx0a
個人簡介:

x0dx0a====bb.asp的會員注冊非法數據監測====x0dx0a<%x0dx0ausername = Request("username")x0dx0auserPassword = Request("userPassword")x0dx0aSex = Request("Sex")x0dx0auserSR = Request("userSR")x0dx0auserNL = Request("userNL")x0dx0aah = Request("ah")x0dx0aswfs = Request("swfs")x0dx0auserGrjs = Request("userGrjs")x0dx0a'判斷數據合法性,絕對不能讓非法數據進入系統x0dx0a'判斷姓名username合不合法,是否包含非法數據x0dx0ausername = Trim(username) '例如:" 張 三 "經過處理之後變成"張 三"x0dx0aIf username ="" Thenx0dx0a Response.write "姓名不能為空"x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf Len(username)>10 Thenx0dx0a Response.write "姓名字數不能超過10個字" 'Len("Z")=1 Len("國")=2x0dx0a Response.Endx0dx0aEnd Ifx0dx0aFor i = 1 To Len(username)x0dx0a q = Mid(username,i,1) x0dx0a If InStr("!@#$%^&*()_-+|<>?/"",.",q)>0 Thenx0dx0a Response.write "姓名不能包含特殊符號!@#$%^&*()_-+|<>?/"",." x0dx0a Response.End x0dx0a End Ifx0dx0aNextx0dx0a'判斷密碼合不合法,是否包含非法數據userPassword = Trim(userPassword)If userPassword ="" Then Response.write "密碼不能為空" Response.EndEnd Ifx0dx0aIf Len(userPassword)>20 Thenx0dx0a Response.write "密碼字數不能超過20個字" x0dx0a Response.Endx0dx0aEnd Ifx0dx0a'判斷密碼合不合法,是否包含非法數據x0dx0aSex = Trim(Sex)x0dx0aIf Sex = "" Thenx0dx0a Response.write "性別不能為空"x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf Sex <> "True" And Sex <> "False" Thenx0dx0a Response.write "性別不能為不男不女"x0dx0a Response.Endx0dx0aEnd Ifx0dx0a'判斷生日合不合法,是否包含非法數據x0dx0auserSR = Trim(userSR)x0dx0aIf userSR ="" Thenx0dx0a Response.write "生日不能為空"x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf Len(userSR)<8 Or Len(userSR)>10 Then '例如:2012-6-3 2012-11-23x0dx0a Response.write "你輸入的生日字數不對,應為2012-6-3或2012-11-23格式" x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf IsDate(userSR)=False Thenx0dx0a Response.write "你輸入的生日格式不能轉化為日期,請核實" x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf DateDiff("yyyy",userSR,Date())<1 Or DateDiff("yyyy",userSR,Date())>200 Thenx0dx0a Response.write "根據你輸入的生日你可能小於1歲或已經超過200歲了,請核查重新輸入" x0dx0a Response.Endx0dx0aEnd Ifx0dx0a'判斷年齡合不合法,是否包含非法數據userNL = Trim(userNL)If userNL ="" Thenx0dx0a Response.write "年齡不能為空" x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf IsNumeric(userNL)=False Thenx0dx0a Response.write "你輸入的年齡不能轉化為數值,請核查"x0dx0a Response.Endx0dx0aEnd Ifx0dx0auserNL = CInt(userNL)x0dx0aIf userNL<0 Or userNL>200 Thenx0dx0a Response.write "你輸入的年齡不能小於0歲或者大於200歲,請核查"x0dx0a Response.Endx0dx0aEnd Ifx0dx0a'判斷愛好合不合法,是否包含非法數據ah = Trim(ah) '選擇多個愛好則系統會用,分開 //測試x0dx0aah = Replace(ah," ","")x0dx0aarrAh = Split(ah,",")x0dx0aFor i = LBound(arrAh) To UBound(arrAh)x0dx0a If arrAh(i)<>"sw" And arrAh(i)<>"ds" And arrAh(i)<>"ty" Then x0dx0a Response.write i & "你選擇的愛好有問題,請核查" & arrAh(i)x0dx0a Response.Endx0dx0a End Ifx0dx0aNextx0dx0a'判斷上網方式合不合法,是否包含非法數據swfs = Trim(swfs)If swfs = "" Thenx0dx0a Response.write "上網方式不能為空"x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf swfs<>"bhsw" And swfs<>"wxsw" And swfs<>"gxsw" Thenx0dx0a Response.write "你選擇的上網方式有問題,請核查"x0dx0a Response.Endx0dx0aEnd Ifx0dx0a'判斷個人簡介是否為空,是否超出1000個字x0dx0auserGrjs = Trim(userGrjs)x0dx0aIf userGrjs = "" Thenx0dx0a Response.write "個人簡介不能為空" x0dx0a Response.Endx0dx0aEnd Ifx0dx0aIf Len(userGrjs) > 1000 Thenx0dx0a Response.write "個人簡介不能超過1000個字"x0dx0a Response.Endx0dx0aEnd Ifx0dx0aResponse.write "數據合法性檢測通過"x0dx0a%>x0dx0a====登陸的HTML代碼可相信樓主參照會員注冊代碼應該沒問題了====

③ 用Dreamweaver做登陸和注冊界面的代碼

用Dreamweaver做登陸和注冊界面的代碼:

登錄頁面:
<script language="JavaScript">
<!--
function check()
{
if (guanli.username.value=="") {
alert ("用戶名不能為空,請輸入用戶名!");
document.huiyuan.username.focus();
return false;
}
if (guanli.password.value=="") {
alert ("密碼不能為空,請輸入密碼!");
document.huiyuan.password.focus();
return false;
}
}
-->
</script>

1、插入一個div,設置為400x300px大小,背景色為米黃色,居中。

2、輸入標題文字和用戶名、密碼,調整位置。

3、繼續插入填寫部分,插入--表單--文本域,所以需要輸入內容的「框」都是文本域。設置用戶名文本域ID為username,點擊確定。

4、繼續同樣的方式插入密碼的文本域,設置ID為password。因為密碼是非明文的,不需要顯示,所以在屬性面板里選擇文本域的類型--密碼。

5、插入按鈕。插入--表單--按鈕,插入兩個按鈕,ID分別設置為login和reg。login按鈕設置為登陸,reg按鈕設置為注冊。

6、初始值是輸入內容時,填寫框顯示的提示文字。

7、這樣一個簡單的登陸界面就做好了。

④ 注冊/登陸頁面HTML代碼該怎麼寫

以下為個人原創教學例子,任何人引用需註明出自網路知道用戶am7972,樓主可供參考
該例子涵蓋了文本框、密碼框、下拉菜單、單選框、復選框及文本區的使用
同時在數據的使用方面涵蓋了文本型、數值型、日期型、布爾型的使用
也涵蓋了在會員信息入資料庫前,進行嚴格的數據檢查
不足處,JS驗證還不是太完善,不過有服務端認證足夠了
<title>會員注冊</title>
<script type="text/javascript">
<!--function CheckForm()
{
if(document.userinfo.username.value == "")
{ alert("請輸入姓名,姓名不能為空!");
document.userinfo.username.focus();
return false;
}
if(document.userinfo.username.value.length > 10)
{
alert("輸入的姓名長度最多為10個字元!");
document.userinfo.username.focus();
return false;
}
}
//--></script>
</head>
<body>
<table border="1" width="53%" bordercolorlight="#000000" cellspacing="0" id="table1" height="358" bordercolor="#000000" bordercolordark="#FFFFFF" cellpadding="0">
<form method="POST" action="bb.asp" name="userinfo" onsubmit="return CheckForm();">
<tr><td colspan="2" height="37"> <p align="center">會員注員</td> </tr>
<tr> <td width="37%" align="right">姓名:</td> <td width="61%"> <input type="text" name="username" value="libin" size="13"> </td> </tr>
<tr> <td width="37%" align="right">密碼:</td> <td width="61%"> <input type="password" name="userPassword" size="20" value="123"></td> </tr>
<tr> <td width="37%" align="right">性別:</td> <td width="61%"><input type="radio" value="True" checked name="Sex">男 <input type="radio" name="Sex" value="False">女</td> </tr>
<tr> <td width="37%" align="right">生日:</td> <td width="61%"> <input type="text" name="userSR" size="11" value="1985-03-12"></td> </tr>
<tr> <td width="37%" align="right">年齡:</td> <td width="61%"><input type="text" name="userNL" size="9" value="13"></td> </tr>
<tr> <td width="37%" align="right">愛好:</td> <td width="61%"> <input type="checkbox" name="ah" value="sw">上網 <input type="checkbox" name="ah" value="ds" checked>讀書 <input type="checkbox" name="ah" value="ty">體育</td> </tr>
<tr> <td width="37%" align="right">上網方式:</td> <td width="61%">
<select size="1" name="swfs"> <option selected value="bhsw">撥號上網</option> <option value="wxsw">無線上網</option> <option value="gxsw">光纖上網</option> </select>
</td> </tr>
<tr> <td width="37%" align="right">個人簡介:</td> <td width="61%"><textarea rows="9" name="userGrjs" cols="34"></textarea></td> </tr> <tr> <td colspan="2" height="38"> <p align="center"><input type="submit" value="提交" name="B1"> <input type="reset" value="重置" name="B2"></td>
</tr>
</form>
</table>
====bb.asp的會員注冊非法數據監測====
<%
username = Request("username")
userPassword = Request("userPassword")
Sex = Request("Sex")
userSR = Request("userSR")
userNL = Request("userNL")
ah = Request("ah")
swfs = Request("swfs")
userGrjs = Request("userGrjs")
'判斷數據合法性,絕對不能讓非法數據進入系統
'判斷姓名username合不合法,是否包含非法數據
username = Trim(username) '例如:" 張 三 "經過處理之後變成"張 三"
If username ="" Then
Response.write "姓名不能為空"
Response.End
End If
If Len(username)>10 Then
Response.write "姓名字數不能超過10個字" 'Len("Z")=1 Len("國")=2
Response.End
End If
For i = 1 To Len(username)
q = Mid(username,i,1)
If InStr("!@#$%^&*()_-+|<>?/"",.",q)>0 Then
Response.write "姓名不能包含特殊符號!@#$%^&*()_-+|<>?/"",."
Response.End
End If
Next
'判斷密碼合不合法,是否包含非法數據userPassword = Trim(userPassword)If userPassword ="" Then Response.write "密碼不能為空" Response.EndEnd If
If Len(userPassword)>20 Then
Response.write "密碼字數不能超過20個字"
Response.End
End If
'判斷密碼合不合法,是否包含非法數據
Sex = Trim(Sex)
If Sex = "" Then
Response.write "性別不能為空"
Response.End
End If
If Sex <> "True" And Sex <> "False" Then
Response.write "性別不能為不男不女"
Response.End
End If
'判斷生日合不合法,是否包含非法數據
userSR = Trim(userSR)
If userSR ="" Then
Response.write "生日不能為空"
Response.End
End If
If Len(userSR)<8 Or Len(userSR)>10 Then '例如:2012-6-3 2012-11-23
Response.write "你輸入的生日字數不對,應為2012-6-3或2012-11-23格式"
Response.End
End If
If IsDate(userSR)=False Then
Response.write "你輸入的生日格式不能轉化為日期,請核實"
Response.End
End If
If DateDiff("yyyy",userSR,Date())<1 Or DateDiff("yyyy",userSR,Date())>200 Then
Response.write "根據你輸入的生日你可能小於1歲或已經超過200歲了,請核查重新輸入"
Response.End
End If
'判斷年齡合不合法,是否包含非法數據userNL = Trim(userNL)If userNL ="" Then
Response.write "年齡不能為空"
Response.End
End If
If IsNumeric(userNL)=False Then
Response.write "你輸入的年齡不能轉化為數值,請核查"
Response.End
End If
userNL = CInt(userNL)
If userNL<0 Or userNL>200 Then
Response.write "你輸入的年齡不能小於0歲或者大於200歲,請核查"
Response.End
End If
'判斷愛好合不合法,是否包含非法數據ah = Trim(ah) '選擇多個愛好則系統會用,分開 //測試
ah = Replace(ah," ","")
arrAh = Split(ah,",")
For i = LBound(arrAh) To UBound(arrAh)
If arrAh(i)<>"sw" And arrAh(i)<>"ds" And arrAh(i)<>"ty" Then
Response.write i & "你選擇的愛好有問題,請核查" & arrAh(i)
Response.End
End If
Next
'判斷上網方式合不合法,是否包含非法數據swfs = Trim(swfs)If swfs = "" Then
Response.write "上網方式不能為空"
Response.End
End If
If swfs<>"bhsw" And swfs<>"wxsw" And swfs<>"gxsw" Then
Response.write "你選擇的上網方式有問題,請核查"
Response.End
End If
'判斷個人簡介是否為空,是否超出1000個字
userGrjs = Trim(userGrjs)
If userGrjs = "" Then
Response.write "個人簡介不能為空"
Response.End
End If
If Len(userGrjs) > 1000 Then
Response.write "個人簡介不能超過1000個字"
Response.End
End If
Response.write "數據合法性檢測通過"
%>
====登陸的HTML代碼可相信樓主參照會員注冊代碼應該沒問題了====

⑤ 編寫用戶注冊於登錄的JSP頁面的全部程序代碼

3個jsp文件,第一個是login.jsp,第二個是judge.jsp,第三個是afterLogin.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登錄頁面</title>
</head>
<body>
<form name="loginForm" method="post" action="judgeUser.jsp">
<table>
<tr>
<td>用戶名:<input type="text" name="userName" id="userName"></td>
</tr>
<tr>
<td>密碼:<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td><input type="submit" value="登錄" style="background-color:pink"> <input type="reset" value="重置" style="background-color:red"></td>
</tr>
</table>
</form>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>身份驗證</title>
</head>
<body>
<%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
String password = request.getParameter("password");
if(name.equals("abc")&& password.equals("123")) {

%>
<jsp:forward page="afterLogin.jsp">
<jsp:param name="userName" value="<%=name%>"/>
</jsp:forward>
<%
}
else {
%>
<jsp:forward page="login.jsp"/>
<%
}
%>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>登錄成功</title>
</head>
<body>
<%
request.setCharacterEncoding("GB18030");
String name = request.getParameter("userName");
out.println("歡迎你:" + name);
%>
</body>
</html>

⑥ 如何用eclipse寫登錄注冊頁面的代碼

java寫的用戶登錄實例,實際頁面展示使用的jsp,那麼下面是jsp的登錄頁面代碼:
1、login.jsp代碼
<%
string name = request.getparameter("username");
string pwd = request.getparameter("password");
//out.println(name+pwd);
string sql ="select * from info where username='"+name+"' and password='"+pwd+"'";
//out.println(sql);
statement stm= null;
resultset rs =null;
try
{
stm = conn.createstatement();
rs = stm.executequery(sql);
if(rs.next())
{
session.setattribute("username",name);
response.sendredirect("index.html");
}
else
{
response.sendredirect("index1.html");
}
}
catch(sqlexception e)
{
e.printstacktrace();
}
%>
<!--登錄的表單-->
<form name="form1" method="post" action="login.jsp">
<p>
<label for="username"></label> 用戶名
<input type="text" name="username" id="username">
</p>
<p>
<label for="passwrod"></label> 密碼
<input type="text" name="passwrod" id="passwrod">
</p>
<p>
<input type="submit" name="button" id="button" value="提交">
</p>
</form>
2、用戶信息表,存放用戶名和密碼:
user_info 表
create table if not exists `test` (
`id` int(8) not null auto_increment,
`username` char(150) default null,
`password` varchar(32),
`times` int(4) not null,
primary key (`id`)
) engine=myisam default charset=utf8 auto_increment=1 ;

閱讀全文

與注冊登錄代碼相關的資料

熱點內容
逍遙安卓微信驗證 瀏覽:579
5g網路什麼時候普及河北邢台 瀏覽:709
編程和運營哪個更適合創業 瀏覽:893
尤里x怎麼升級 瀏覽:399
做業務績效考核需要哪些數據 瀏覽:433
dnf85版本劍魔刷圖加點 瀏覽:407
手機硬碟測試架可以讀取哪些數據 瀏覽:704
ug前後處理結算結果找不到文件 瀏覽:769
網頁框架拆分代碼 瀏覽:382
未來十年網路安全有什麼影響 瀏覽:362
win10更新後進不了劍靈 瀏覽:243
iphone471激活出錯 瀏覽:648
怎麼把文件拷到u盤 瀏覽:620
中伊簽署文件視頻 瀏覽:661
電信光寬頻網路不穩定 瀏覽:504
網路崗軟路由 瀏覽:995
黑莓z10在哪裡下載app 瀏覽:310
net批量下載文件 瀏覽:696
怎麼把蘋果一體機文件拷貝 瀏覽:117
sql文件怎麼寫 瀏覽:9

友情鏈接