HTML CODE HERE
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">
使用此<form id="cool" name ="form" action ="hi.php" method="post">
而不是<form id="cool" name ="form" action ="hi.php">