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
jim_73_mk1
Forum Newbie
Posts: 15 Joined: Mon Nov 24, 2003 9:42 pm
Contact:
Post
by jim_73_mk1 » Sun Nov 30, 2003 6:20 am
I'm trying to fill a text field with a value passed from a form on a previous page. The problem is the text passed ($Title) is all there but in the text box it only shows the first word. I found another way to display all the text but it will be tedious to code. Maybe someone can explain why the two processes work differently?
Code: Select all
<?php
$Title = "This is New Stuff";
print ("
<form action='NewBook.php' method='post' name='EditBook'>
<table width=80% cellspacing=5>
<tr>
<td></td>
<td><strong>Your Book Information</strong></td>
<td><strong>Matching Book Information</strong></td>
</tr>
<tr>
<td>Title</td>
<td><input name='Title' type='text' value=" . $Title . "></td>
<td></td>
</tr>
<tr>
<td>Title</td>
");
?>
<td><input name='Title' type='text' value=" <?php print $Title; ?> "></td>
<?php
print ("
<td></td>
</tr>
</table>
</form>
");
?>
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Sun Nov 30, 2003 6:29 am
WHy don't you just do like this?;
Code: Select all
<?php
$Title = "This is New Stuff";
echo <<<EOD
<form action="NewBook.php" method="post" name="EditBook">
<table width="80%" cellspacing="5">
<tr>
<td></td>
<td><strong>Your Book Information</strong></td>
<td><strong>Matching Book Information</strong></td>
</tr>
<tr>
<td>Title</td>
<td><input name="Title" type="text" value="$Title"></td>
<td></td>
</tr>
</table>
</form>
EOD;
?>
mchaggis
Forum Contributor
Posts: 150 Joined: Mon Mar 24, 2003 10:31 am
Location: UK
Post
by mchaggis » Sun Nov 30, 2003 11:50 am
Just a note... single quotes within html tags isn't allowed, you have to use double quotes, so vigge89's answer is probable the best way to do it or:
Code: Select all
<?php
$Title = "This is New Stuff";
?>
<form action="NewBook.php" method="post" name="EditBook">
<table width="80%" cellspacing="5">
<tr>
<td></td>
<td><strong>Your Book Information</strong></td>
<td><strong>Matching Book Information</strong></td>
</tr>
<tr>
<td>Title</td>
<td><input name="Title" type="text" value="<?=$Title?>"></td>
<td></td>
</tr>
</table>
</form>
?>
One thing to look out for tho is if $Title contains a double quote it will break you out of the input box....