1

I have a form like this:

<form action="/web/" method="get">
<input type="search" name="keyword_search_query">
<input type="submit" value="Search…">
</form>

This is a search form for my website.

What is the right/common way to encode these data into a search query to avoid unexpected behavior?

For instance, having an & in one of the inputs will cut the search query. How should I escape those characters?

P.S. How does Google do it?

Jérôme
  • 13,328
  • 7
  • 56
  • 106
  • Possible duplicate of [How to properly URL encode a string in PHP?](http://stackoverflow.com/questions/4744888/how-to-properly-url-encode-a-string-in-php) – Jérôme Mar 02 '17 at 13:49

1 Answers1

0

User encodeURI(data); for encoding

Sazzad Hussain
  • 321
  • 1
  • 3
  • 11