【发布时间】:2022-01-19 11:12:19
【问题描述】:
我使用 GET 方法将数据从 index.php 传递到 profile.php
index.php 代码是
<html>
<body>
<form action="profile.php" method="GET">
username: <input type="text" username="user"><br>
password: <input type="password" name="pass"><br>
<input type="submit">
</form>
<button type="button" onclick="alert('task success')"/>click me"</button>
</body>
</html>
profile.php 代码是
<?php
echo " username: "$_GET ['username']."; password "$_GET['pass'];
?>
它成功传递了表单的输入,但我需要它出现在 profile.php 文件中
如何使输出出现在 profile.php 页面中?
请帮忙
【问题讨论】:
-
用户名的
input标签应该是<input type="text" name="username">。 -
在您的 html 代码中删除
click me之后的"并删除click me之前的/(在<button>标记的末尾)。在您的 profile.php 中,将当前句子更改为echo " username: ".$_GET['username']." password: ".$_GET['pass'];并在另一条评论中进行 @kenny 修复。错别字太多。使用更好的代码编辑器来帮助您修复它们,例如 Virtual Studio Code 或 Sublime