2
傳遞未編碼的網址
我在首頁上設置了一個搜索框,它應該通過傳遞URL鏈接到Opencart搜索。從表單
我遇到的問題是,所產生的URL始終未編碼:
store/index.php?route%3Dproduct%2Fsearch%26filter_name=test
什麼我的目標是
store/index.php?route=product/search&filter_name=test
我當前的代碼是:
<?php
$storesearch = $_REQUEST['store-search'] ;
$filter = 'route=product/search&filter_name';
$filtered = html_entity_decode($filter);
?>
<form id="store" method="GET" action="http://localhost/vinmobile/store/index.php?<?php echo $storesearch; ?>">
<input type="text" id="store-search" name="<?php echo $filtered; ?>" value="Store Search" onclick="this.value = '';">
<input type="submit" name="" value="Search">
</form>
<?php echo $filtered; ?> // Just to show it onscreen to make sure it's written correctly
我已經試過編碼,解碼,html_entity_decode,urldecode,rawurldecode ... 我已經試過形式方法GET, POST
我已經試過變量聲明爲$_REQUEST, $_GET, $_POST
每一次,我還是結束與網址看起來像:
store/index.php?route%3Dproduct%2Fsearch%26filter_name=test
我敢肯定這件事情簡單的我已經錯過了,但我覺得「我用盡了一切,他很感激,如果有人能在正確的方向指向我。
乾杯
webecho
你試過第一次做了'utf8_decode'? https://stackoverflow.com/a/1756925/6577664 – Mike
我沒有,但它仍然沒有工作...... '$ filter ='route%3Dproduct%2Fsearch%26filter_name'; $ filtered = utf8_decode(urldecode($ filter));' 也試過: '$ filter ='route = product/search&filter_name'; $ filtered = utf8_decode(urldecode($ filter));' – webecho
將路由添加到表單動作如何? ie'action = index.php?route = product/search'然後給你的搜索字段保持一致的名字,比如'search' –