Hi!
I'm using PHP in order to redirect some search query. There is some example of code here (click).
And my PHP code is:
audio_action.php :
<?php
$search_field = trim($_POST['audio_field']);
$search_engine = trim($_POST['audio']);
$url_params = preg_replace('/(\ )+/', '+', $search_field);
$url = array('deezer'=>'http://www.deezer.com/s.php?s=', 'jiwa'=>'http://www.jiwa.fm/#search/track/', 'last.fm'=>'http://www.last.fm/music?q=');
header('Location:'.$url[$_POST['audio']].$url_params)
?>
and video_action.php :
<?php
$search_field = trim($_POST['video_field']);
$search_engine = trim($_POST['video']);
$url_params = preg_replace('/(\ )+/', '+', $search_field);
$url = array('youtube'=>'http://www.youtube.com/results?search_type=&amp;search_query=', 'dailymotion'=>'http://www.dailymotion.com/relevance/search/', 'google_video'=>'http://video.google.com/videosearch?q=');
header('Location:'.$url[$_POST['video']].$url_params)
?>
The problem is that I can't use it when search terms must be in the middle of an url.
For example, for Jiwa it should be: http://www.jiwa.fm/#search/track/{%22q%22%3A%22keywords%22}
Where "keywords" is the place where keywords should be.
And without those %22} characters search doesn't work.
So how to improve this PHP code in order to make it work with such query?
Somebody told me too that $search_engine = trim($_POST['video']); is useless, but when I remove it, it doesn't work anymore.
I'm currently using video_action.php for video search and audio_action.php for audio but if you find some way to merge those file into a single one while keeping 2 forms in my HTML code it would be awesome.
Please help me improve this code.
PS: I don't want to use JavaScript for this.