此处为 HTML 代码
php代码中for循环的一些错误
<html>
<head><title>Hello
</title></head>
<body>
<form id="cool" name ="form" action ="hi.php">
<input type ="text" name="m1" value="m1"/>
</br><input type ="text" name="m2" value="m2">
</br><input type ="text" name="m3" value="m3">
</br><input type ="text" name="m4" value="m4">
</br><input type ="text" name="m5" value="m5">
<input type="submit" >
</form>
</body>
</html>
这是 php 代码,它在第 6 行说未定义索引,这里 mem 正在获取值 m1,m2,m3,m4,但是从 mem 中提取值不起作用
<?php
for ($i = 1; $i < 5; $i++) {
$mem = 'm' . $i;
$m = $_POST[$mem];
print " The member is" . $m . "</br>";
}
?>
最佳答案
您需要在表单标签中添加method="POST"
<form id="cool" name ="form" action ="hi.php" method="POST">
关于php - 变量值不能分配给另一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32413154/