HTML表单传值示例通过get方式传递
- 作者: 乐天22704346
- 来源: 51数据库
- 2020-08-15
HTML表单传值,就是一个input输入框和input提交按钮,需要注意的是type为submit而不是button,具体示例如下,不了解的朋友可以看看哦
google.html界面如图
代码如图:(比较简单,就是一个input输入框和input提交按钮,注意type为submit,而不是button)
<html>
<head>
<title>Winbobo</title>
</head>
<body>
<div align="center">
<form action="google.php" method="get">
<input name="q" type="text"/>
</br>
<input name="btnSearch" type="submit" value="Search" />
</form>
</div>
</body>
</html>
google.php的代码如图:($_GET用于获取表单通过get方式传递的数据; $_POST用于获取表单通过post方式传递的数据)
<?php
print "<pre>";
print_r($_GET);
print "</pre>";
?>
运行结果如图:
代码如图:(比较简单,就是一个input输入框和input提交按钮,注意type为submit,而不是button)
复制代码
代码如下:<html>
<head>
<title>Winbobo</title>
</head>
<body>
<div align="center">
<form action="google.php" method="get">
<input name="q" type="text"/>
</br>
<input name="btnSearch" type="submit" value="Search" />
</form>
</div>
</body>
</html>
google.php的代码如图:($_GET用于获取表单通过get方式传递的数据; $_POST用于获取表单通过post方式传递的数据)
复制代码
代码如下:<?php
print "<pre>";
print_r($_GET);
print "</pre>";
?>
运行结果如图:
推荐阅读
