2

我想在 PHP 中获取文本框的值,当我尝试这个时:

<form method=post action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />  
</form>
<?php
$test = $_POST['Hex'];
echo $test;
?>      

我只是得到错误:

未定义索引:十六进制

我用谷歌搜索无济于事;所以请有人帮助我!

4

4 回答 4

6

i think the issue is with the quotation marks, @GuiceU you forgot to add the quotes to post.

Just replace your method = post with method="post"

HTML code:

<form method="post" action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />  
</form>

php code:

<?php
               $test = $_POST['Hex'];
               echo $test;
?>  
于 2012-04-30T11:06:32.150 回答
6

我希望这可以帮助你:

    <?php
if (isset($_POST['submit'])) {
$test = $_POST['Hex'];
echo $test;
} else { ?>
<form method="post" action="">
<input type="text" name="Hex" />
<input type="submit" value="OK" name="submit" />  
</form>
<?php } ?>
于 2012-04-28T19:55:19.047 回答
0

你的代码看起来不错。不过,你可以试试这个:

使您的表格如下所示:

<form method="post" action="update.php">

并尝试使用$_REQUEST而不是$_POST

于 2012-04-28T19:26:49.943 回答
0

在脚本开头使用

<?php error_reporting(E_ALL ^ E_NOTICE); ?>
于 2012-12-22T07:36:49.013 回答