Problem with Default value in text box using PHP

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
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Problem with Default value in text box using PHP

Post by szms »

I am trying to keep a default text in a text box. But if I try to use couple of words having spase in between it just only taking the first word. I want to show the couple of words in the text box. How can I do that?

Here is my code...... I am passing the sentence through $Name
$Name = "Hello World";

But it's unly showing "Hello" in the text box.

<input type="text" name="Domain_Name[]" value = <?php print "$Name";?> size = "30">
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Re: Problem with Default value in text box using PHP

Post by nielsene »

[Mod's please move to -Normal]

szms wrote:I am trying to keep a default text in a text box. But if I try to use couple of words having spase in between it just only taking the first word. I want to show the couple of words in the text box. How can I do that?

Here is my code...... I am passing the sentence through $Name
$Name = "Hello World";

But it's unly showing "Hello" in the text box.

<input type="text" name="Domain_Name[]" value = <?php print "$Name";?> size = "30">
You are missing the quotes around the value try

Code: Select all

<input type="text" name="Domain_name&#1111;]" value = "<?php echo "$Name";?>" size ="30">
(I like echo better than print, but there is really no difference....) However either print or echo do not add quotes around the string, unless you manually add them. I added them to the raw HTML. If you wanted to add them to the string, you would do
<?php echo ""$Name"";?>
The " tells PHP to actually print a quote, not to end the current string.
Post Reply