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

html登錄注冊代碼

發布時間:2024-03-01 07:38:35

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,還請選擇合適的瀏覽器查看。


② 注冊/登陸頁面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代碼可相信樓主參照會員注冊代碼應該沒問題了====

③ 用html javascript做一個用戶注冊窗口,要求實現登錄名不為空,且兩次密碼輸入一致的功能

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button onclick="dengRu()">登入</button>
<button onclick="zhuCe()">注冊</button>
</body>
</html>
<script type="text/javascript">
var a1;var b1;
var a2;var b2;
var a3;var b3;

var ciShu = 1;
function zhuCe(){
alert("歡迎進入注冊界面");
if(ciShu == 1){
a1 = prompt("請注冊您的賬號");
if(a1==""||==null){
alert("賬號不能為空")
}else{
b1 = prompt("請注冊您的密碼");
if(b1==""||b1==null){
alert("密碼不能為空")
}else if(ciShu== 2){
a2 = prompt("請注冊您的賬號");
if(a2==""||a2==null){
alert("賬號不能為空");
}else{
b2 = prompt("請注冊您的密碼");
if(b2==""||b2==null){
alert("密碼不能為空")
}else if(ciShu== 3){
a3 = prompt("請注冊您的賬號");
if(a3==""||a3==null){
alert("賬號不能為空")
}else{
b3 = prompt("請注冊您的密碼");
if(b3==""||b3==null){
alert("密碼不能為空")
}else{
}
console.log("第"+ciShu+"次注冊");
console.log("賬號1為"+a1+",密碼1為"+b1);
console.log("賬號2為"+a2+",密碼2為"+b2);
console.log("賬號3為"+a3+",密碼3為"+b3);
ciShu++;
}
}
}
}
}
}
}

function dengRu(){
alert("歡迎進入登入界面");
var zhangHao = prompt("請輸入您的賬號");
var miMa = prompt("請輸入您的密碼");
if(zhangHao==a1&&miMa==b1||zhangHao==a2&&miMa==b2||zhangHao==a3&&miMa==b3){
alert("登錄成功")
}else{
alert("登錄失敗")
}
}
</script>

④ 資料庫里創建好了登錄賬號和密碼 怎麼連接HTML登錄按鈕啊 麻煩指點一下 幫我寫下代碼 謝謝

前端 html 用form 指向後台 LOGIN.PHP

<html>
<head>用戶登錄</head>
<formname="LoginForm"method="post"action="login.php"onSubmit="returnInputCheck(this)">
<p>
<labelfor="username"class="label">用戶名:</label>
<inputid="username"name="username"type="text"class="input"/>
<p/>
<p>
<labelfor="password"class="label">密碼:</label>
<inputid="password"name="password"type="password"class="input"/>
<p/>
<p>
<inputtype="submit"name="submit"value="確定"class="left"/>
</p>
</form>
</html>

後台 login.php

<?php
//登錄
if(!isset($_POST['submit'])){
exit('非法訪問!');
}
$username=htmlspecialchars($_POST['username']);
$password=MD5($_POST['password']);

//包含資料庫連接文件
include('conn.php');
//檢測用戶名及密碼是否正確
$check_query=mysql_query("select*fromuser_listwhereusername='$username'andpassword='$password'limit1");
if($result=mysql_fetch_array($check_query)){
//登錄成功
session_start();
$_SESSION['username']=$username;
$_SESSION['userid']=$result['userid'];
echo$username,'歡迎你!進入<ahref="my.php">用戶中心</a><br/>';
echo'點擊此處<ahref="login.php?action=logout">注銷</a>登錄!<br/>';
exit;
}else{
exit('登錄失敗!點擊此處<ahref="javascript:history.back(-1);">返回</a>重試');
}//注銷登錄
if($_GET['action']=="logout"){
unset($_SESSION['userid']);
unset($_SESSION['username']);
echo'注銷登錄成功!點擊此處<ahref="login.html">登錄</a>';
exit;
}

?>
閱讀全文

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

熱點內容
手機後台網路怎麼關閉 瀏覽:537
大數據安徽 瀏覽:563
iphone鎖屏密碼能破解嗎 瀏覽:964
電信運營商大數據徵信 瀏覽:699
怎麼u盤里的文件打不開 瀏覽:97
如何發word文件怎麼打開 瀏覽:176
惠普還原系統win10教程 瀏覽:167
iphone6ssunspider 瀏覽:796
java獲取攝像頭 瀏覽:959
怎麼用網線傳文件 瀏覽:24
電導增量法matlab程序 瀏覽:366
手機文件管理在那裡 瀏覽:205
如何取消卸載app的續費 瀏覽:316
數控編程哪個最容易 瀏覽:170
光速互動官方教程 瀏覽:411
谷歌登陸網站打不開怎麼辦 瀏覽:937
java什麼是非同步編程 瀏覽:898
怎麼刪除qq裡面的文件 瀏覽:503
qq鈴聲設置的鈴聲文件在哪裡找 瀏覽:421
有哪些有助於考公的app 瀏覽:237

友情鏈接