我想在 PHP 中获取文本框的值,当我尝试这个时:
<form method=post action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />
</form>
<?php
$test = $_POST['Hex'];
echo $test;
?>
我只是得到错误:
未定义索引:十六进制
我用谷歌搜索无济于事;所以请有人帮助我!
我想在 PHP 中获取文本框的值,当我尝试这个时:
<form method=post action="update.php">
<input type="text" name="Hex" />
<input type="submit" value="OK" />
</form>
<?php
$test = $_POST['Hex'];
echo $test;
?>
我只是得到错误:
未定义索引:十六进制
我用谷歌搜索无济于事;所以请有人帮助我!
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;
?>
我希望这可以帮助你:
<?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 } ?>
你的代码看起来不错。不过,你可以试试这个:
使您的表格如下所示:
<form method="post" action="update.php">
并尝试使用$_REQUEST
而不是$_POST
在脚本开头使用
<?php error_reporting(E_ALL ^ E_NOTICE); ?>