Re: variables problem

From: Date: Fri, 27 Jun 2003 14:08:12 +0000
Subject: Re: variables problem
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-20599@lists.php.net to get a copy of this message
<morris71@libero.it> escribió en el mensaje news:001301c33cac$78e5bf70$a200a8c0@ARIETE... > Hi Felipe. > First of all... the lacking double-quotes at the end ot the string! So, the > right way is: > header("Location: validation.php?name=$name&mail=$mail&message=$message"); > This line works well if... > > Regarding your "question", the problem is in a uncorrect usage of the > variables while composing the Location string. Follow me: > > 1. consider you have a name composed of 2 or more "words". For instance: > $name="Felipe Lorente"; (but the same for $mail and $message). > When expading/substituting $name in the "header" function you have exactly > this: > header("Location: validation.php?name=Felipe Lorente&mail..... > As you can see the string has a "blank" space inside, so PHP thinks the > string ends to "Felipe", avoiding the rest!!! > > 2. it's a normal behaviour for PHP :-) > > 3.the correct syntax when working with URLs is to transform "normal values" > in "url-encoded values". That is to translate in a understandable way the > strings passed as URLs to a browser (in fact, when you call a Location, it's > the same as you type that URL directly in the browser). So before calling > Header("Location... make the following: > $name=urlencode($name); > $message=urlencode($message); > ... > This function will transform all "strange" character in the string in > special values (i.e., "Felice Lorente" becomes "Felipe+Morente". As you can > see not more 2 differents words but just ONE!!! > > 4. While retrieving urlencoded values from validation.php, you must > (obviously :-) url-decode these values. So in validation.php before using > URL-passed params you have to: > $name=urldecode($name) > $message=urldecode($message) > ... > > I hope these notes can help you. > > > Bye > -- > Francesco > morris71@libero.it > > Ok, thanks, now it is working perfectly. I didnt know the urlencode function. Regards, Felipe.

« previous php.windows (#20599) next »