-2

Id basically like the below submission to place text at the end of the url

example of what i want

http://example.com/(text) -- without the () obviously

example of what i don't want -- 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 like to fix this via html or php either will do aslong as it submits the request to that :)

thank you in advance.

  • possible duplicate of [URL rewriting with PHP](http://stackoverflow.com/questions/16388959/url-rewriting-with-php) – Jeremiah Winsley Nov 26 '14 at 18:51
  • a duplicate??? lol no i don't want to rewrite an url i want it to correctly post the text into the url > http://www.example.com/(example)..... – Darren Brinx Nov 26 '14 at 20:08

2 Answers2

0

Using the POST method instead of GET.

<form action="" method="POST">
<fieldset>
 search name
<br>
<input type="text" name="search" value="name">
<br>
<input type="submit" value="Submit"></fieldset>
</form>
0

In short you do the following:

<?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>
vicente
  • 2,613
  • 4
  • 22
  • 27