- 相關(guān)推薦
如何實(shí)現(xiàn)PHP獲取表單數(shù)據(jù)與HTML嵌入PHP腳本
導(dǎo)語(yǔ):如何實(shí)現(xiàn)PHP獲取表單數(shù)據(jù)與HTML嵌入PHP腳本,下面是小編給大家提供的操作講解,大家可以參考閱讀,更多詳情請(qǐng)關(guān)注應(yīng)屆畢業(yè)生考試網(wǎng)。
常用的自動(dòng)全局變量如下所示:
1、GET方式
功能:獲取get方式提交的數(shù)據(jù)
格式:$_GET[“formelement”]
2、POST方式
功能:獲取post方式提交的數(shù)據(jù)
格式:$_POST[“formelement”]
3、REQUEST方式
功能:獲取任意方式提交的數(shù)據(jù),$_REQUEST自動(dòng)全局變量包含了所有GET、POST、COOKIE和FILE的數(shù)據(jù),如不關(guān)心數(shù)據(jù)來(lái)源。
格式:$_REQUEST[“formelement”]
復(fù)選框 、列表框(名稱采用數(shù)組形式如:"select[]",在獲取其值的時(shí)候直接使用$_POST["select"]即可)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無(wú)標(biāo)題文檔</title>
</head>
<body>
<!--獲取表單數(shù)據(jù)的兩種方法-->
<!--post-->
<form method="post" action="8.3.php" name="form1">
<table border="1" width="400" cellpadding="0" cellspacing="0">
<tr>
<td height="30"> 用戶名:<input name="txtName" type="text" size="12">
密碼:<input name="txtPsd" type="password" size="12">
<input type="submit" name="SubmitBtn" value="提交">
</td>
</tr>
</table>
</form><br/>
<!--get URL的長(zhǎng)度需要限定在1M范圍內(nèi),否則會(huì)截取-->
<!--可以使用urlencode與urldecode對(duì)URL進(jìn)行編解碼-->
<form method="get" action="8.3.php" name="form2">
<table border="1" width="400" cellpadding="0" cellspacing="0">
<tr>
<td width="400" height="30"> 訂單號(hào):<input name="txtFrame" type="text" size="12">
<input type="submit" name="SubmitBtn">
</td>
</tr>
</table>
</form>
<!--在Web頁(yè)面中嵌入PHP腳本-->
<?php
$strTxt = '男';
?>
<input type="text" value="<?php echo "strTxt"; ?>">
</body>
<?php
echo '用戶名: '.$_POST["txtName"]." 密碼:".$_POST['txtPsd'];
echo '訂單號(hào):'.$_GET["txtFrame"];
?>
</html>
【如何實(shí)現(xiàn)PHP獲取表單數(shù)據(jù)與HTML嵌入PHP腳本】相關(guān)文章:
PHP如何獲取表單07-27
如何在HTML中嵌入PHP代碼11-07
PHP如何使用curl實(shí)現(xiàn)數(shù)據(jù)抓取09-27
如何使用php獲取excel文件數(shù)據(jù)10-17
如何讓php提交form表單11-06
PHP實(shí)現(xiàn)獲取FLV文件的時(shí)間07-27