2015-09-05 45 views
1

HTML代码在这里变量值不能被分配到另一个可变

某些错误与在PHP代码

<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>"; 
} 
?> 
+0

谢谢您指定的HTML表单代码。 – nlips

+0

添加方法=“发布”在您的窗体标签 –

回答

8

您需要在您的表单标签添加method="POST"

<form id="cool" name ="form" action ="hi.php" method="POST"> 
+0

非常感谢,没有注意到:) –

+0

欢迎@alertpay尽情享受! – Saty

2

使用本<form id="cool" name ="form" action ="hi.php" method="post">

代替 <form id="cool" name ="form" action ="hi.php">

+0

谢谢,让它工作:) –