wariar
asked on
Spaces in a parameter
How can I send a parameter with spaces from my HTML form to the CGI script?
ASKER
I use the POST method. Everytime there is a space in the parameter eg: "Mr Jack", it reads only "Mr".
<form method=POST action=/cgi-bin/CGI_script ?fn=Mr+Jac k>
If the paramater is passed by user input it will preserve the spaces. If you do a paramater dump, it will show up with %20 replacing the spaces. If you assign the paramater to a variable, the varaible will contain the text that the user typed with the spaces showing up as spaces. If you are trying to specify the paramaters within a program make sure that the whole text is within quotes, if double quotes do not work then use single quotes. If that still does not work, use %20 where you would like to have a space, since that is how it will be encoded anyway.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The browser will convert spaces and any other special characters before it passes them to the CGI script.
if you have used <form MEthod=get ...> in the HTML tag, then you can, in fact see this in the URL itself!!
Eg.
you form has a HTML element
<form action=/cgi-bin/CGI_script
<input type=text name=fn value="Mr Jack">
<P><input type=submit>
</form>
and you have used method=get then the URL will appear like so...
http://www.biffo.com/cgi-bin/CGI_script?fn=Mr+Jack