将来自文本字段的输入存储在 PHP 变量中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4088082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Store input from a text field in a PHP variable
提问by Mike
Store the users input from a text field in a variable. Any ways to do this?
将用户从文本字段输入的内容存储在变量中。有什么方法可以做到这一点?
回答by dotariel
HTML:
HTML:
<input type="text" name="firstname" />
PHP-onsubmit (untested)
PHP-onsubmit(未经测试)
<?php
$firstname = $_POST["firstname"];
?>
回答by oezi
if you have a form with that textarea and you submit that form, you'll have the value in your global $_GET
or $_POST
-array (depending on whats the methot of your form).
如果您有一个带有该 textarea 的表单并提交该表单,您将在 global$_GET
或$_POST
-array 中拥有该值(取决于您的表单的方法)。
you can access this value by typing $_GET['nameofyourtextarea']
(or the same with $_POST
)
您可以通过键入$_GET['nameofyourtextarea']
(或与 相同$_POST
)来访问此值