Reputation: 7487
I am trying to see if URL encoding of GET parameters while submitting a form is possible. I have seen a few resources where URL encoding is being is used where the URLs are built dynamically
Example: www.google.com?query=urlencode($query)
But how do I apply the function urlencode() if I am using a form and a submit button?
<html>
<body>
<form action="send.php" method="get">
<input type="input" name="method" value="" />
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
Upvotes: 0
Views: 4784
Reputation: 642
This is done by the browser if you ask it to do it. Consider using enctype="application/x-www-form-urlencoded":
<html>
<body>
<form action="send.php" method="get" enctype="application/x-www-form-urlencoded">
<input type="input" name="method" value="" />
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
Note that it is done by default in most modern browsers if you don't even specify enctype.
Upvotes: 2
Reputation: 2120
The browser will urlencode them for you. Go to google and search for "&", and you'll see "q=%26" in the URL.
Upvotes: 3