PHP實現擷取表單資料與HTML嵌入PHP指令碼

來源:互聯網
上載者:User
本篇文章主要介紹PHP實現擷取表單資料與HTML嵌入PHP指令碼,感興趣的朋友參考下,希望對大家有所協助。

php接受通過HTML表單提交的資訊時,會將提交的資料儲存在全域數組中,我們可以調用系統特定的自動全域變數數組來擷取這些值。

常用的自動全域變數如下所示:

1、GET方式

功能:擷取get方式提交的資料

格式:$_GET[“formelement”]

2、POST方式

功能:擷取post方式提交的資料

格式:$_POST[“formelement”]

3、REQUEST方式

功能:擷取任意方式提交的資料,$_REQUEST自動全域變數包含了所有GET、POST、COOKIE和FILE的資料,如不關心資料來源。

格式:$_REQUEST[“formelement”]

複選框 、列表框(名稱採用數組形式如:"select[]",在擷取其值的時候直接使用$_POST["select"]即可)

<!doctype html><html><head><meta charset="utf-8"><title>無標題文檔</title></head><body><!--擷取表單資料的兩種方法--><!--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的長度需要限定在1M範圍內,否則會截取--><!--可以使用urlencode與urldecode對URL進行編解碼--><form method="get" action="8.3.php" name="form2"> <table border="1" width="400" cellpadding="0" cellspacing="0"> <tr>  <td width="400" height="30"> 訂單號:<input name="txtFrame" type="text" size="12">  <input type="submit" name="SubmitBtn">  </td> </tr> </table></form><!--在Web頁面中嵌入PHP指令碼--><?php  $strTxt = '男';?><input type="text" value="<?php echo "strTxt"; ?>"></body><?php  echo '使用者名稱: '.$_POST["txtName"]." 密碼:".$_POST['txtPsd'];  echo '訂單號:'.$_GET["txtFrame"];?></html>

以上就是本文的全部內容,希望對大家的學習有所協助。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.