0

%2F我有一个表格,当你点击搜索时,它会用斜杠而不是斜杠写出 url 。我怎样才能解决这个问题?

代码:

<form name="cdsearch" method="get" action="">
<input type="hidden" name="route" value="database/comics" /> <-- This is where the slash is needed
<input style="width: 100%;" type="text" name="q" value="<?php echo $q ?>" /><br/>
<input style="width: 100%;" type="submit" value="Search Comic Database" />      
</form>
4

1 回答 1

1

尝试

<form name="cdsearch" method="POST" action="redir.php">
  <input type="hidden" name="route" value="database/comics" /> <-- This is where the slash is needed
  <input style="width: 100%;" type="text" name="q" value="<?php echo $q ?>" /><br/>
  <input style="width: 100%;" type="submit" value="Search Comic Database" />      
</form>

重发文件

<?php 

if($_POST){ //check that the form has been posted
    $route = url_decode($_POST['route']);
    $query = $_POST['query'];
    //echo $_POST['route']." has been changed to ".$route; // <--- for testing
    header("Location: ".$route."/?query=".$query);  // redirect the user now the url has been decoded
    exit();
}

?>
于 2012-11-07T10:07:10.877 回答