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
ssand
Forum Commoner
Posts: 72 Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa
Post
by ssand » Sun Jan 29, 2006 10:46 am
Hi,
I need a little help. I have a form field that I want to echo the value.
Right now I have this code and it's not working.
Code: Select all
<?php echo "value=\"".$_POST['fn']."\""; ?>
I added an echo statement just outside the form field for $_POST['fn'] and the contents are displayed no problem.
EDIT:
I have also tried this varient as well and doesn't seem to work
Code: Select all
<?php echo "value=".$_POST['fn']; ?>
Thank you
raghavan20
DevNet Resident
Posts: 1451 Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:
Post
by raghavan20 » Sun Jan 29, 2006 10:52 am
Code: Select all
<input type = 'text' name = 'input_name' value = '<?php echo $_POST["value"]; ?>' />
Last edited by
raghavan20 on Sun Jan 29, 2006 10:58 am, edited 2 times in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Jan 29, 2006 10:53 am
more code would be helpful. What type of form element are we talking here?
ssand
Forum Commoner
Posts: 72 Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa
Post
by ssand » Sun Jan 29, 2006 10:56 am
sorry feyd
Code: Select all
<input type="text" name="fn" <?php echo "value=\"".$_POST['fn']."\""; ?> size="25">
ssand
Forum Commoner
Posts: 72 Joined: Sat Jun 22, 2002 9:25 pm
Location: Iowa
Post
by ssand » Sun Jan 29, 2006 12:33 pm
Well, it works as raghavan20 suggested.
Is it something with forms that the value= needed to be outside the php?
Thanks
jayshields
DevNet Resident
Posts: 1912 Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England
Post
by jayshields » Sun Jan 29, 2006 1:44 pm
No it's not. At a glance I can't really see what's wrong with your original code, but there are many alternatives to rag's method, none of which necessarily involve keeping the value attribute outside of the PHP.