Putting variables into this URL

I’m looking for some PHP code to enter a search string into a URL. It should take spaces into account. The endresult for the term ‘philips led’ should be:

http://www.someurl.com/nl/product.nsf/queryreviews?readform&qcode=0&q=philips+and+led&pcode=0&gq=philips%20led

Script is already in place, it uses this format for other search actions:

header("Location: http://www.someurl.com/search.php?&q=" . stripslashes($_POST["input_text"]));

So I guess it should look a bit like that only smarter :)

Any thoughts?

Are you asking how to “Generate” a URL in that format?

I am not really sure what you are looking for. Perhaps more details could help.

Thanks for your reply. There already is a script in place that takes any search terms and inserts them into the URL that matches the selected radio button. Now I just need to expand that with this a bit more demanding type URL. As you see this URL isnt just blabla?q= but it uses 2 ways of handling any space characters. So I need the line of code that can correctly translate multiple search terms in the URL provided.

You can parse the variable that contains the date that you need. There are multiple ways of doing this including regular expressions. you can then take that data and put it back in to the “New and Improved” Url for presentation.

I’m just looking for some line of code to try, thanks for your time so far anyways.

Well what exactly are you trying to take from the one, and make into the other and HOW is it getting there?

For example are you actually entering the url in a browser and submitting it (Using the GET method) and then “RE-Directing” (Based upon the HEADER function) to the “New” URL?

I am not really sure how to answer your question because I am not really sure what your question is.

I’m sorry, these are the first few lines of the code, perhaps that answers your tech question.

<?php if (isset($_POST["input_text"]) && ($_POST["input_text"] != "") && isset($_POST["options"])) {

	switch ($_POST["options"]) {

		case 1:

			header("Location: http://www.vinden.nl/?query=" . stripslashes($_POST["input_text"] . "&where=web"));

			break;

Is this impossible?

Did it not provide the required info? Lost here…

Sponsor our Newsletter | Privacy Policy | Terms of Service