
批改狀態(tài):合格
老師批語:表單是html最復(fù)雜的元素了, 細(xì)節(jié), 坑, 實(shí)在是太多了, 以后一定要多加小心
在之前的課程中,我們知道了表單是除了url之外,與后臺(tái)進(jìn)行交互的唯一入口。因此表單的重要性,不言而喻。
此案例,通過實(shí)現(xiàn)簡(jiǎn)單的用戶登錄與注冊(cè)功能,達(dá)到練習(xí)表單的各個(gè)種類與屬性的目的。
<iframe>
控件中默認(rèn)顯示login.html中的內(nèi)容<iframe>
控件中加載register.html的內(nèi)容在main.html中主要練習(xí)內(nèi)聯(lián)框架
<form action="login.php" method="POST" class="register">
<label for="username">帳號(hào):</label>
<input type="text" id="username" name="username" value="" placeholder="請(qǐng)輸入用戶名"/>
<label for="pwd">密碼:</label>
<input type="password" id="pwd" name="pwd" value="" placeholder="請(qǐng)輸入密碼"/>
<button>提交</button>
</form>
<form action="register.php" method="post" class="register" enctype="multipart/form-data">
<label for="user_pic">頭像:</label>
<input type="file" name="user_pic" id="user_pic">
<div class="user_pic" style="grid-column: 2"></div>
<label for="username">賬號(hào):</label>
<input type="text" name="username" id="username" value="" placeholder="用戶名不少于6個(gè)字符" >
<label for="passwd">密碼:</label>
<input type="password" name="password" id="passwd" value="" placeholder="輸入密碼">
<label for="ensure">確認(rèn):</label>
<input type="password" name="ensure" id="ensure" value="" placeholder="確認(rèn)兩次密碼相同">
<label for="secret">性別:</label>
<div>
<input type="radio" name="sex" value="man" id="man" ><label for="man">男</label>
<input type="radio" name="sex" value="woman" id="woman"><label for="woman">女</label>
<input type="radio" name="sex" value="secret" id="secret" checked><label for="secret">保密</label>
</div>
<label for="email">郵箱:</label>
<input type="email" name="mail" id="email">
<label for="eduction">學(xué)歷</label>
<select name="eduction" id="eduction" >
<option value="1">無學(xué)歷</option>
<option value="2">小學(xué)</option>
<option value="3">初中</option>
<option value="4">高中</option>
<option value="5" selected>???/span></option>
<option value="6">本科</option>
<option value="7">本科以上</option>
</select>
<button>提交</button>
<button type="reset">重置</button>
</form>
<header>
<div>
<a href="register.html" class="button" target="content">會(huì)員注冊(cè)</a>
</div>
</header>
<aside>
</aside>
<main>
<iframe name="content" src="login.html"></iframe>
</main>
雖然,在本次案例中,并沒有使用到全部的表單類型,但練習(xí)了比較常用的幾種類型。有一些知識(shí)點(diǎn),需要加深記憶并掌握理解。
multipart/form-data
,這樣數(shù)據(jù)會(huì)以二進(jìn)制的編碼進(jìn)行提交,并且 method
方法要設(shè)置為postname
屬性,將單選按鈕進(jìn)行分組name
屬性設(shè)置成一個(gè)數(shù)組,這樣有助于后端程序?qū)?shù)據(jù)進(jìn)行處理<iframe>
控件的作用主要是,在當(dāng)前的頁面中,嵌入另一個(gè)html頁面,類似于手機(jī)中的畫中畫應(yīng)用微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)