[GRLUG] PHP & <textarea>
Nathan Phillip Brink
binki at gentoo.org
Mon Nov 14 18:55:32 EST 2011
On Mon, Nov 14, 2011 at 05:45:02PM -0600, L. V. Lammert wrote:
> Trying to fix some problems with a website, .. it retrieves event data and
> displays on the screen if existing, if new, it displays a template to
> enter Home & Away teams:
>
> <div class="formLabel">Teams</div><div class="formElement">
> <textarea rows="2" cols="30" name="event_title" id="event_title_game">
> <?php echo (empty($event_title)?"H: \n A: \n" : $event_title); ?>
> </textarea>
> </div>
>
> The text area seems to have a number of spaces preceeding either the data
> or the 'template', and there seem to be no clues how to prevent it. More
> interesting is the fact that there ARE no leading spaces IN the DB!
I think that's because <textarea/>s are akin to <pre/>s. Your template
has a newline, three spaces, a newline, and another space in addition
to the data produced by the <?php ?> snippet.
Another note, you're forgetting to escape the data you're pulling from
the database. The template should probably look like:
<div class="formLabel">Teams</div><div class="formElement">
<textarea rows="2" cols="30" name="event_title" id="event_title_game"><?php echo htmlentities(empty($event_title) ? "H: \n A: \n" : $event_title); ?></textarea>
</div>
--
binki
Look out for missing or extraneous apostrophes!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://shinobu.grlug.org/pipermail/grlug/attachments/20111114/5300cc05/attachment.pgp>
More information about the grlug
mailing list