I want a simple form with one text box and a submit button. For example: If a user enters "foobar" into the text box and hits enter, they should be redirected to mysite.com/browse/foobar
Does anyone know how I can开发者_如何学运维 do this in php? thanks
Assuming name='q' for the text input
<?php
    if ($_GET['q'] === "foobar") {
        header("Location: http://example.com/browse/foobar");
    }
?>
The Form:
<form action="index.php" method="get">
<input type="text" name="q" />
<input type="submit" />
</form>
index.php
header("Location: http://example.com/browse/".$_GET['q']);
Note: this is not good practice but it works.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论