PHP - 无法获取文本字段值

时间:2014-03-25 16:49:17

标签: php html

我是PHP的新手,我在下面提到了我的HTML和PHP代码。我无法将文本框值获取到PHP。我在下面提到了HTML和PHP代码。

HTML代码:

Section <input type="text" name="f_b1_s1_sec" id="f_b1_s1_sec">
Content <input type="text" name="f_b1_s1_con" id="f_b1_s1_con"><br><br> 
Para <input type="text" name="f_b1_s1_para" id="f_b1_s1_para">

PHP代码:

$tx0 = $_POST["f_b1_s1_sec"];
$tx1 = $_POST["f_b1_s1_con"];
$tx2 = $_POST["f_b1_s1_para"];

请澄清。

谢谢!

1 个答案:

答案 0 :(得分:2)

试试这个:

<?php
if( isset( $_POST["go"] ) {
  $tx0 = $_POST["f_b1_s1_sec"];
  $tx1 = $_POST["f_b1_s1_con"];
  $tx2 = $_POST["f_b1_s1_para"];
}
?>

<form action="insertyourphp.php" method="post">
Section <input type="text" name="f_b1_s1_sec" id="f_b1_s1_sec">
Content <input type="text" name="f_b1_s1_con" id="f_b1_s1_con"><br><br> 
Para <input type="text" name="f_b1_s1_para" id="f_b1_s1_para">
<input type="submit" name="go" value="Go">
</form>