PHP - 将变量从一个页面带到另一个页面并使用
我是一个真正的初学者,如果我犯了严重的错误,我很抱歉!
我想要做的事情我知道很简单,但我在文档中找不到相关帮助。
我想从“产品”页面中取出四个变量,然后我想将它们作为 html 表单的值发布,但我不知道如何做。
变量来自managebooks.php,需要在ammendbook.php中使用。
在managebooks.php中,我到ammendbook.php的链接如下:
echo "<tr>";
echo "<td>";
echo "<a href='amendbook.php?bookname=".$bookname."&bookauthor=".$bookauthor."&bookpub=".$bookpub."&bookisbn=".$bookisbn."'>Amend Entry</a>";
echo "</td>";
我希望将这四个变量带到下一页(ammendbook.php),我的表单代码如下:
<form id="adminlogin" name="login" action="amendbookupdate.php" method="post">
Book Title <br />
<input type="text" name="booktitle" value="<?php echo $bookname; ?>"></input><br />
Book Author(s)<br />
<input type="text" name="bookauthor" value="<?php echo $bookauthor; ?>"></input><br />
Book Publisher<br />
<input type="text" name="bookpub" value="<?php echo $bookpub; ?>" ></input><br />
ISBN-10 number (non-standard format)<br />
<input type="text" name="bookisbn" value="<?php echo $bookisbn; ?>"></input><br /><br />
<input type="submit" name="submit" value=" - Update Database - "></input>
</form>
我不确定还要包括什么,我尝试制作一个数组来看看这是否可行(因此回显变量如下所示:
<?php
$bookname['bookname'] = $_GET['bookname'];
$bookauthor['bookauthor'] = $_GET['bookauthor'];
$bookpub['bookpub'] = $_GET['bookpub'];
$bookisbn['bookisbn'] = $_GET['bookisbn'];
?>
但是这是错误的。
我也尝试在表单中输入:
<input type="text" name="booktitle" value="<?php echo $_SESSION['bookname'] ?>"></input><br />
但这也是错误的!
任何想法伙计们..
提前感谢您的阅读和任何帮助
!
I am a real beginner at this so sorry if I am makin awfull mistakes!
Want I want to do I know is very simple but I cant find the relevant help in my documentation.
I want to bring four variables out of a 'product' page, I then want to post these as the values of an html form but I am not sure how.
The variables come from managebooks.php and need to be used in ammendbook.php.
In managebooks.php my link to ammendbook.php is as follows:
echo "<tr>";
echo "<td>";
echo "<a href='amendbook.php?bookname=".$bookname."&bookauthor=".$bookauthor."&bookpub=".$bookpub."&bookisbn=".$bookisbn."'>Amend Entry</a>";
echo "</td>";
This i expected to bring that four variables with me to the next page (ammendbook.php) my form code is as follows:
<form id="adminlogin" name="login" action="amendbookupdate.php" method="post">
Book Title <br />
<input type="text" name="booktitle" value="<?php echo $bookname; ?>"></input><br />
Book Author(s)<br />
<input type="text" name="bookauthor" value="<?php echo $bookauthor; ?>"></input><br />
Book Publisher<br />
<input type="text" name="bookpub" value="<?php echo $bookpub; ?>" ></input><br />
ISBN-10 number (non-standard format)<br />
<input type="text" name="bookisbn" value="<?php echo $bookisbn; ?>"></input><br /><br />
<input type="submit" name="submit" value=" - Update Database - "></input>
</form>
I am not sure what else to include, I tried making an array to see if that would work (hense the echo variables like this:
<?php
$bookname['bookname'] = $_GET['bookname'];
$bookauthor['bookauthor'] = $_GET['bookauthor'];
$bookpub['bookpub'] = $_GET['bookpub'];
$bookisbn['bookisbn'] = $_GET['bookisbn'];
?>
But this is wrong.
I also in the form attempted to just put:
<input type="text" name="booktitle" value="<?php echo $_SESSION['bookname'] ?>"></input><br />
but this is also wrong!
Any ideas guys..
Thank you in advance for reading and any help!
[=
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
至
然后随意使用,
无需声明。
例如:
test1.php:
test2.php
To
Then feel free to use
Without declaring.
FOR EXAMPLE:
test1.php:
test2.php
只需尝试:
在 ammendbook.php 的顶部,然后通过这些名称引用这些变量。这不是您要找的吗?我可能很困惑。
编辑:在将来自 GET 或 POST 数组的变量分配给变量之前,您应该始终对其进行清理。
Just try:
At the top of ammendbook.php and then refer to those variables by those names. Is that not what you're looking for? I may be confused.
Edit: You should always sanitize variables that come from the GET or POST arrays before assigning them to variables.