error in transferring value got from a form to the other

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashiitk
Forum Newbie
Posts: 1
Joined: Thu Sep 27, 2007 2:45 pm

error in transferring value got from a form to the other

Post by ashiitk »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,
   I have made a form form1.php-
[syntax="html"]
<form method="post" action="form2.php" >	
<input name="var" type="text">
<input type="submit" name="submit1" >


I put in var="This is variable"

in the next page form2.php -[/syntax]

Code: Select all

if($_SERVER["REQUEST_METHOD"]=="POST" && $_POST["submit1"]) {
 $var = $_POST["var"];
 echo $var;
}

<form method="post" action="form3.php" >	
<input name="var" type="hidden" value="<?=$var?>">
<input type="submit" name="submit2">


I got the output - "This is variable"
fine till now

Then in next page form3.php -

Code: Select all

if($_SERVER["REQUEST_METHOD"]=="POST" && $_POST["submit2"]) {
 $var = $_POST["var"];
 echo $var;
}
I got output - "This" :(

Where all string gone ??? why it is showing only first word ??? please help


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by ashiitk on Thu Sep 27, 2007 3:41 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

This usually means that you've forgotten quotes on a value attribute somewhere.

value="a b c"
instead of value=a b c
Post Reply