如何在提交php表单后显示当前网址的文字

时间:2017-10-17 14:13:10

标签: php html

如何在提交表单后显示当前网址的文字 www.example.com/?n=Example-Text

<form method="post" action="/submit.php">
    <div class="enter-name">
        <input class="animated pulse infinite" type="name" required="" maxlength="50" name="n" placeholder="Enter Your Text Here">
        <button class="btn" type="submit"><span>></span> Go</button>
    </div>
</form>

3 个答案:

答案 0 :(得分:1)

如果要显示输入name="n"中的文字,
制作表单方法GET <form method="get" action="/submit.php">

并在 submit.php

<?php
echo $_GET['n'];
?>

答案 1 :(得分:0)

当您的代码的响应为GET响应时,如表格标记POST

中所示,您询问<form method="post" action="/submit.php">请求

对于您提供的示例, submit.php 页面需要具有以下代码

<?php echo $_POST['n']; ?>

这将显示内联通过表单提交后名称=“n”输入中的值。

如果您想要查看传递给网址中 submit.php 文件的信息,则需要更改HTML以使用get方法替代表单当前使用的post

答案 2 :(得分:-1)

<form method="post" action="/submit.php">
<div class="enter-name">
    <input class="animated pulse infinite" type="name" required="" maxlength="50" name="n" placeholder="Enter Your Text Here">
    <button class="btn" type="submit"><span>></span> Go</button>
</div>
</form>

你必须设置get方法而不是post, 将传递参数传递给url,称为urlencodded,

<form method="get" action="/submit.php">
相关问题