probably a simple question however I am not the best at PHP.
I’ll show you the code first:
$prodTitle = $_GET['prodName'];
$html = file_get_html('http://www.play.com/Search.html?searchtype=allproducts&searchsource=0&searchstring='.$prodTitle.'');
Hopefully you can understand what I am trying to do. In this case $prodTitle would be the keyword coming from a text input form. However the problem is that the website I am putting $prodTitle into will not accept spaces into its search string.
So if I where to search for Transformers Box Set using my search form the search will not work. Currently I have to put in Transformers+Box+Set to get it to work.
Is there a way to add in the “+” without having to write it in my search form?
Any help would be greatly appreciated!
Thank you.
You can fix it with
urlencode()like this:Docs: http://nl.php.net/urlencode
Also, make sure it is safe. Never trust any input from users.