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>

redir.php

<?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 に答える