search

Home  >  Q&A  >  body text

$_POST[] cannot get the value, why???

echo <<<'FORM'

<form action="" method="post">

<input type="number" name = "rows">行

<br/>

<input type="number" name = "cols">列

<input type="submit" value="提交";

</form>

FORM;


$rows = isset($_POST['rows']) ? $_POST['rows'] : 3;

$cols = isset($_POST['cols']) ? $_POST['cols'] : 3;

// $rows = $_POST['rows'];

// $cols = $_POST['cols'];

echo '<table border="1" cellspacing="0" cellpadding="5">';

$i = 0;

while ($i<$rows) {

echo '<tr>';

$j = 0;

while ($j<$cols) {

echo '<td>'.($i * $cols $j).'</td>';

$j ;

}

echo '</tr>';

$i ;

}

echo '</table>';

代码如上,获取不到行和列的数值

ԾvԾ人人余耳总ԾvԾ人人余耳总1974 days ago1577

reply all(2)I'll reply

  • 清音Susunma~

    清音Susunma~2019-06-20 16:01:32

    Change the value of the action in the form to the current file name, like this<form action="xx.php" method="post">

    reply
    0
  • ԾvԾ人人余耳总

    Well, if I go home and write on two separate pages, it’ll be fine. It was found that the form did not have a closing tag and the syntax was wrong. Sorry for wasting your time

    ԾvԾ人人余耳总 · 2019-06-20 16:04:18
  • Cancelreply