我一直在寻找并试图找到我的代码有什么问题已经有一段时间了,如果我仍然不知道我的代码有什么问题,我就不会问这个问题。 基本上我正在回复一个get表单,有一个php脚本,就像这样的动作:
<?php
//Add a team list and list members to each team.
$memq = "SELECT members.id, teams.team_name, teams.stage, teams.points, members.member1 FROM members INNER JOIN teams ON teams.team_name=members.team_name";
$memres = mysql_query($memq) or die ('Couldnt display members'.mysql_error());
echo "<br> Teams, Stage & Members: <br>";
while ($memrow = mysql_fetch_assoc($memres))
{
$team_name = $memrow['team_name'];
echo "<form method='get' action='addOne.php'><input type='hidden' name='team_name' value='$team_name'><input type ='submit' name='team_name' value='+1'></form> ";
echo "<form method='get' action='addTwo.php?team_name=$team_name' value='<?php echo $team_name;?>'><button type ='submit'>+2</button></form> ";
echo "<form method='get' action='addTen.php?team_name=$team_name' value='<?php echo $team_name;?>'><button type ='submit'>+10</button></form> ";
echo $memrow['id'] . " | " . $memrow['team_name'] . " | " . $memrow['stage'] . " | " . $memrow['member1'] . " | " . $memrow['points'] . "<br>";
}
?>
我一直在玩它并尝试过各种各样的事情(在表单声明中有value =
字段等等),但是当我在浏览器中检查检查器时,它说:
<form method="get" action="addOne.php?team_name=asda">
<input type="hidden" value="asda">
<input type="submit" value="+1"></form>
因此,您可以看到该值实际已设置,但表单提交必须无效,因为addOne.php(if
)中的if (isset($_GET['team_name']))
语句始终返回false。
我在这里错过了一些非常简单的东西吗?感谢提前感谢。 :)
答案 0 :(得分:2)
问题是您在表单的action属性中使用GET变量。如果你设置方法=&#39;得到&#39;以及在那里使用get变量的操作,它们将被删除并用表单中的变量覆盖。它应该遵循HTML:
<form method="get" action="addOne.php">
<input type="hidden" name="team_name" value="asda">
<input type="submit" value="+1">
</form>
并且PHP应如下所示:
$team_name = $memrow['team_name'];
echo "<form method='get' action='addOne.php'><input type='hidden' name='team_name' value='$team_name'><input type ='submit' value='+1'></form> ";
&#13;
答案 1 :(得分:1)
您需要将名称属性放在输入标记中,如下所示
<div class="editor-field">
@Html.EditorFor(model => model.message.Replace(Environment.NewLine, "<br/>")), new { rows = "6", cols = "500" })
@Html.ValidationMessageFor(model => model.message)
</div>
然后,cecibe值如:
<input type="hidden" name="var_1" value="asda" />