如何使提交按钮与PHP代码一起使用以显示表单中输入的数据?[已结束]

how do i make the submit button work with php code to show the data entered in the form? [closed]

提问人:Yahir Hernández 提问时间:11/18/2023 更新时间:11/18/2023 访问量:29

问:


Stack Overflow 是一个纯英文网站。作者必须能够用英语交流,以理解和参与他们收到的任何评论和/或回答。不要为作者翻译这篇文章;机器翻译可能不准确,甚至人工翻译也会改变帖子的预期含义。

6天前关闭。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <form action="servidor.php" method="post">
            <label for="nombre">Nombre</label><br>
            <input type="text" id="name" name="nombre" placeholder="Nombre de usuario"><br>
            <label for="password">Password</label><br>
            <input type="password" id="password" name="contraseña" placeholder="Contraseña"><br>
            <button type="submit">Enviar</button>
    </form>
</body>
</html>

Esto es lo que he puesto en mi archivo php que ya ubique en en la misma carpeta de mi html

<?php
        echo htmlspecialchars($_POST['name']);
    ?>
<?php
        echo htmlspecialchars($_POST['password']);
    ?>

No funciona, me carga lo siguiente:imagen del resultado que no quiero

Yo quiero un resultado así: imagen del resultado que sí quiero

Espero se haya entendido mi problema, es sencillo pero ya busque y no di con una explicación especifica de esto.

php html 表单 输入 提交

评论

0赞 Stefino76 11/18/2023
您需要在服务器内部进行测试。你可以使用 Xampp、easyphp 或在真实的服务器上测试它
0赞 ZeNix 11/18/2023
Primero que nada, trata de hacer los post en inglés o usa stackoverflow en español, Tienes que usar un servidor como Xamp, o iniciar , de la forma que más te convenga.php -S localhost:8000
1赞 ZeNix 11/18/2023
此外,您期望一个名为 and 的 post 值,但在您的表单中,您发送的输入称为 和 。您希望在发布时收到属性,而不是 .namepasswordnombrecontraseñanameid

答: 暂无答案