UBB.Dev
Posted By: Basil Fawlty Spaces getting removed - 11/13/2006 7:39 PM
I'm trying to build an integrated page that requires input from the user via a forum. The variable in the form gets passed to the "script" file ok, but the space between words gets removed, so, for example, "Austin Healey" (a selection from a drop down on my form) becomes: "AustinHealey". Any idea why this happens and is there anything I can do about it?

Thanks,
Basil
Posted By: chillin Re: Spaces getting removed - 11/14/2006 12:06 AM
is your form using POST or GET? Maybe the variable isn't being encoded properly.
Posted By: Basil Fawlty Re: Spaces getting removed - 11/14/2006 3:50 AM
Like this:

Code
<FORM ACTION="ubbthreads.php?ubb=mypage" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded"> 
Posted By: chillin Re: Spaces getting removed - 11/14/2006 9:53 PM
And what does your input array look like on mypage.inc.php... maybe you have the resulting field being mapped incorectly?
Posted By: Micky Re: Spaces getting removed - 11/14/2006 10:46 PM
Hi,
tries sometimes these two lines from header.tpl out increase.

Quote


Posted By: Basil Fawlty Re: Spaces getting removed - 11/14/2006 11:24 PM
Originally Posted by chillin
is your form using POST or GET? Maybe the variable isn't being encoded properly.

It looks like this:
PHP Code
"input" => array(
// This is an array of variables that you expect from the user
// "varname" => array("fieldname","requesttype","vartype");
// requesttype can be either "get", "post" or "both"
// vartype can be "int", "alpha", "alphanum" or just blank if it can contain any characters
"var1" => array("var1","post","alpha"),


Where var1 is the variable name that gets past via the form input. If the selection on the form is, for example, "Michael Jordan" then that gets passed in the var1 variable, but when it gets to the script file, (.inc.php) it looses the space and becomes "MichaelJordan"
Posted By: chillin Re: Spaces getting removed - 11/15/2006 1:15 AM
Thats whats stripping the spaces from your variable

change your var input to

Code
"var1" => array("var1","post",""),

and the preg_replace function that is stripping your spaces won't mess with your variable anymore!
Posted By: Basil Fawlty Re: Spaces getting removed - 11/15/2006 3:46 AM
YES!!! That did it! Thanks! I guess the answer was right there in front of my face the whole time: "or just blank if it can contain any characters" and somehow I just zoned that out.

Basil
Posted By: chillin Re: Spaces getting removed - 11/15/2006 7:24 PM
we've all been there. i for the life of me couldn't figure out why a file upload form I made wasn't working, when after 30 mins I realized that i had my form encoding wrong.
Posted By: Basil Fawlty Re: Spaces getting removed - 11/17/2006 12:59 AM
Yeah, sometimes the simplest problems can take the longest to figure out because your not looking for the obvious!
Posted By: Gizmo Re: Spaces getting removed - 11/17/2006 3:27 AM
lol, its all new though, so at least its understandable
© UBB.Developers