Link to home
Start Free TrialLog in
Avatar of wariar
wariar

asked on

Spaces in a parameter

How can I send a parameter with spaces from my HTML form to the CGI script?
Avatar of maneshr
maneshr

you dont have to worry about embeded spaces in your data.
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 method=get>
<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
Avatar of wariar

ASKER

I use the POST method. Everytime there is a space in the parameter eg: "Mr Jack", it reads only "Mr".
Avatar of ozo
<form method=POST action=/cgi-bin/CGI_script?fn=Mr+Jack>
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
Avatar of HedgeMaze
HedgeMaze

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial