首頁  >  文章  >  後端開發  >  web開發N例-案例3:使用post和get方法在php和html間傳遞參數

web開發N例-案例3:使用post和get方法在php和html間傳遞參數

WBOY
WBOY原創
2016-08-08 09:29:34954瀏覽

web開發N例

案例3:使用post和get方法在php和html間傳遞參數

case3.php:

<!DOCTYPE html>
<html>
<head>
    <!-- 请将文档保存为UTF-8编码,否则中文会乱码 -->
    <meta charset="UTF-8">
    <title>案例3</title><!-- 使用post和get方法在php和html间传递参数 -->
</head>

<body>

<!-- 使用get方法传递 -->
<form action="case3-output.php" method="get">
    get提交的数据:<input type="text" name="getText">
    <input type="hidden" name="getHidText" value="get隐藏文字">
    <input type="submit" name="g_sb"><!--提交按钮,只有提交了才能够传递表单参数-->
</form>

<!-- 通过url直接传递,也属于get方法 -->
<a href="case3-output.php?urlText=传递文字">点击超链接传递参数</a>

<!-- 使用post方法传递 -->
<form action="case3-output.php" method="post">
    post提交的数据:<input type="text" name="postText" >
    <input type="hidden" name="postHidText" value="post隐藏文字">
    <input type="submit" name="p_sb"><!--提交按钮,只有提交了才能够传递表单参数-->
</form>

</body>

</html>

casereoutee詳盡了,不需要再說明了。


以上就介紹了web開發N例-案例3:使用post和get方法在php和html間傳遞參數,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn