2016-06-09 59 views
-1

Is there anyway to carry a value in php forward to a second page?尝试在HTML和PHP

我试图做类似的什么人在这个岗位回答的东西结转的值,但它告诉我,我是不确定的。我相信这是因为我试图在行动之后使用 ?i =而不是链接。此外,我将需要我作为一个变量,而不是常数。这是可能的,我将如何解决这个问题?

echo '<form action="gallery.php?i=0" method="post"> 
<input type="submit" name="action" value="Previous"> 
<input type="submit" name="action" value="Next">'; 
+0

[PHP:“Notice:Undefined variable”和“Notice:Undefined index”]的可能重复(http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-索引号) –

+0

***少***好人知道,***更多时间***为您提供解决方案和意见将会持续增长,直到我们确切地知道哪些动物是在这里处理。你也可能会失去人们对这个问题的兴趣,这取决于他们想要坚持多久。我自己,有一个5分钟。宽限期为“无相关代码”问题。我知道这听起来可能是正确的,但我有更好的事情要做,而不是像其他人一样等待。而这5分钟已经过去了。 –

回答

1

在生成表单的php中使用隐藏输入及其值。

至少我认为这是你问的问题。

<input type="hidden" name="i" value="/* here goes your variable*/" 
+0

我只是试过,但它似乎认为我的变量是在html – dane

+0

echo'';该指数在phpstorm中显示为绿色,而不是橙色。 – dane

+0

@dane这是因为在一个单独的字符串中,变量不像在双引号中那样被解析。 http://php.net/manual/en/language.types.string.php#language.types.string.parsing – Christopher

0

我会建议使用:

<input type="hidden" name="i" value="0" /> 

要转发值。但请记住,恶意用户可以操纵此值,因此您应该始终验证它以及其他字段。