Reputation: 75
HTML CODE HERE
Some error with the for loop in the php code
<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>
This is the php code, it says undefined index at line 6 , here mem is getting value m1 ,m2,m3,m4, but extracting the value from mem is not working
<?php
for ($i = 1; $i < 5; $i++) {
$mem = 'm' . $i;
$m = $_POST[$mem];
print " The member is" . $m . "</br>";
}
?>
Upvotes: 1
Views: 95
Reputation: 105
use this <form id="cool" name ="form" action ="hi.php" method="post">
instead
<form id="cool" name ="form" action ="hi.php">
Upvotes: 2
Reputation: 22532
You need to add method="POST"
in your form tag
<form id="cool" name ="form" action ="hi.php" method="POST">
Upvotes: 8