我想将 variale 从 URL 传递到输入文本字段
您好,我有一个网址 http://example.com/sr_web/confirm_place/index.php?student=123456&surname=test&firstname=Bugsy
,我希望获取学生、姓氏和名字通过执行
但值没有显示。如果我删除输入框并仅 echo 本身 中的 ?>。但是当我写下以下内容时:
<input type="text" name="student" id="student" value="<?php echo $_GET["student"]; ?>">
输入框显示为空白。
它正在通过(我检查了源代码),但没有显示在输入框中,任何人都可以帮忙吗?
Hi I have a URL http://example.com/sr_web/confirm_place/index.php?student=123456&surname=test&firstname=Bugsy
, I want the student, surname and forename to get displayed into my input text boxes by doing <?php echo $_GET['surname']; ?>
But value is not getting displayed. It is getting displayed if I remove the input box and only echo itself <?php echo $_GET["student"]; ?>
within the <td>
. But when I write the following:
<input type="text" name="student" id="student" value="<?php echo $_GET["student"]; ?>">
input box get displayed blank.
It is getting passed (I checked the source) but does not get displayed in the input box, can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要将 $_GET 变量的值放入
value
属性中。执行此操作时,您还需要运行htmlentities
。You need to put the value of the $_GET variable in the
value
attribute. You also want to runhtmlentities
when doing this.仅检查来源,您可能会忽略一些事情。执行
如果姓氏没有出现在屏幕上的某个位置,则表示出现了问题。
尝试编写如下内容:
但不在 php 标签内。
Checking the source alone, you could have overlooked something. Do a
If the surname is not appearing somewhere on the screen, something is wrong.
Try to write something like this:
but not within php tags.
我能想象的唯一会导致这种情况的是 GET 的错误使用。您确定您使用的是 GET 而不是 POST。网址是否显示 myurl.html?firstname=john&surname=smith
The only thing I can imagine that would cause this would be an incorrect use of GET. Are you sure that you are using GET and not POST. Is the url displaying myurl.html?firstname=john&surname=smith