Re: Passing variable

From: Date: Fri, 08 Sep 2000 09:00:11 +0000
Subject: Re: Passing variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-15846@lists.php.net to get a copy of this message
stohs@wmdata.com (Ohlson Stefan) writes: > I'm having problems with passing a variable ($message). > When I echo it in select_items.php3 it shows the correct data. > But when I echo it in the recieving script, ordered_items.php3, it just > shows the first 2-3 letters. > > --------------------select_items.php3----------------------------------- > <? (...) > print "<FORM METHOD='POST' ACTION='./ordered_items.php3' > TARGET='bottom'>\n"; > print "<INPUT TYPE=HIDDEN NAME='items' VALUE=$message>\n"; > print "</FORM>\n"; > ORA_CLOSE($cursor); > ORA_LOGOFF($handle); > print "</FORM>"; > print "message=$message"; //Shows 1, Dickens, Charles, A Christmas > carol, 0-00-370078-X > print "</BODY></HTML>"; > ?> > > ---------------------ordered_items.php3------------------------------- > <? > mail("xxx@xxx.xxx","Order",$items, "From: yyy@yyy.yyy"); > > print "<HTML><HEAD><TITLE></TITLE></HEAD><BODY > bgcolor='#D6D6D6'>"; > echo "items=$items"; //Shows 1, > print "</BODY></HTML>"; > ?> The problem's in the HTML generated. You're producing a form element like this: <INPUT TYPE=HIDDEN NAME='items' VALUE=1, Dickens, Charles, A Christmas> The browser is interpreting that as a hidden input of name 'items' and value '1,' with three other attributes that it doesn't understand and so ignores. You need to quote the value if there's ever the possibility that it'll have spaces in. In fact quote it anyway. print "<INPUT TYPE=HIDDEN NAME='items' VALUE='$message'>\n"; -robin -- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK Email: robin@planet-three.net Phone: +44 (0)870 729 5444

« previous php.general (#15846) next »