Reply to Re: Passing '+' gives trouble.

Your name:

Reply:


Posted by Hilarion on 09/30/05 17:44

> > > I'm passing some text from one page to the other which holds a '+' in
> > > the
> > > text:
> > >
> > > $text = "regeling + formaat"
> > >
> > > stap5.php?text=regeling%20+%20formaat
> >
> > This link is bad. How did you made it?
> > You should do it like this:
> >
> > $link = 'stap5.php?text=' . urlencode( $text );
> >
> >
> > > I can see this being passed in the URL bar, but my $_get doesn't pick it
> > > fully up.
> > > $_get['text'] gives me $text="regeling formaat"
> >
> > Because plus sign in URLs means space. If you use "urlencode", then
> > the problem will not appear. One more thing: do not use "urlencode"
> > when passing values in <input> fields - use "htmlspecialchars"
> > instead. If you use "urlencode" in <input>, then you'll have to
> > "urldecode" it on the page which gets the data, which makes
> > script more messy and gives nothing better than "htmlspecialchars"
> > does.
>
> This what the url in the browser displays, its not the code ;-)
> stap5.php?text=regeling%20+%20formaat

I know and this URL is bad. I assumed you are generating the URL (your
code is doing this) basing on the code fragment you gave ($text =
"regeling + formaat"). In that case the code is wrong (it should use
"urlencode"). If it's not your code, then you have no good way
to fix the the values you are getting. In url parameter values
the "+" sign and "%20" code both mean space character. If someone
wants to pass "+" sign in the URL, he should encode it (or pass
it in <input> fields in a <form> submited by GET method - this
way it's the browser who is doing the value encoding, so you
do not have to "urlencode" it).


> Anyway, thank a lot Hilarion, got it all workin now!

I'm happy to hear that.


Hilarion

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация