nicob Posted March 30, 2009 Share Posted March 30, 2009 With this code I get http://www.mydomain.com/search/page.php?q=blabla+blabla <form method="get" action="search/page.php"> <fieldset> <input type="text" name="q" value="" /> <input type="submit" value="search" /> </fieldset> Now I want this result => http://www.mydomain.com/search/-blabla+blabla-1-1-10-and.html or http://www.mydomain.com/search/-blabla-1-1-10-and.html but I don't know how! Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/ Share on other sites More sharing options...
Brian W Posted March 30, 2009 Share Posted March 30, 2009 you could post the "search" to a page where it is then processed like that. Example: <?php if($_GET['q'] > ''){ $stuff = "-1-1-10-and"; header('location: search/'.$_GET['q'].$stuff.'.html'); die(); } else { echo "you did not enter anything for the search"; } this being said, I'm not sure what your doing with this or even how this will work once you have achieved what you asked in this thread. Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797013 Share on other sites More sharing options...
nicob Posted March 30, 2009 Author Share Posted March 30, 2009 Thank you for the code, Brian. But I was looking for a manipulation from the search form. I'm not sure what your doing with this By using 'RewriteRule' in htaccess I can visit a search result in this way => http://www.mydomain.com/search/-blabla+blabla-1-1-10-and.html . But when I use the search field I get the old url => http://www.mydomain.com/search/page.php?q=blabla+blabla and I don't want this to show for the users anymore! Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797030 Share on other sites More sharing options...
Brian W Posted March 30, 2009 Share Posted March 30, 2009 I was going to recommend mod rewrite if you came back not knowing what you were doing. Cheers Brian Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797034 Share on other sites More sharing options...
nicob Posted March 30, 2009 Author Share Posted March 30, 2009 By the way. Your code works very well. I added $replace = str_replace(" ", "+", "$_GET[q]"); to replace the spaces. Thx! If it's not possible to manipulate the search form, then this topic is solved. Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797062 Share on other sites More sharing options...
Brian W Posted March 30, 2009 Share Posted March 30, 2009 solved then to my knowledge, I've never seen any kind of method besides possibly javascript to do what you are looking for using the form. You could use JS, but the php code is simpler. Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797070 Share on other sites More sharing options...
nicob Posted March 31, 2009 Author Share Posted March 31, 2009 PHP is indeed better than js. So this topic is solved as there is no other solution. Thx! Link to comment https://forums.phpfreaks.com/topic/151786-solved-form-fieldhow-do-i-get-this-url-after-searching/#findComment-797647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.