将结果提交到 URL 的末尾,而不是添加索引.php


submitting result to the end of the url instead of adding an index.php

Id 基本上就像下面的提交一样,将文本放在 url 的末尾

我想要的例子

http://example.com/(文本) -- 显然没有 ()

我不想要的例子 - http://www.example.com/index.php?firstname=text

<form action="(end of current url)">
<fieldset>
 search name
<br>
<input type="text" name="search" value="name">
<br>
<input type="submit" value="Submit"></fieldset>
</form>

id喜欢通过HTML或PHP解决此问题,只要它将请求提交给该:)

提前谢谢你。

使用 POST 方法而不是 GET。

<form action="" method="POST">
<fieldset>
 search name
<br>
<input type="text" name="search" value="name">
<br>
<input type="submit" value="Submit"></fieldset>
</form>
简而言之,

您可以执行以下操作:

<?php 
    // Get posted text
    $text = strtolower(mysql_real_escape_string($_POST['text']));
    // Do some cleanup here
    // Redirect to page
    if ($text != ''){
        header( 'Location: http://www.example.com/' . $text );
    }
    // HTML output below (not before)
?>    
<form method="post" action="">
    <fieldset>
        Search name<br />
        <input type="text" name="text" /><br />
        <input type="submit" value="Submit" />
    </fieldset>
</form>