Connecting Tech Pros Worldwide Forums | Help | Site Map

Text Area Forms and How Data is Stored

Robizzle
Guest
 
Posts: n/a
#1: Oct 12 '05
I'm having problems with an html textarea and how the input is
interpreted in php. For instance, new lines aren't being carried over
in my news posts.

Currently this is what i'm doing:
makenews.php takes form data from makenews.php and spits it out to the
first file that doesn't already exist of the name template
news.file.I.txt where I starts at 0 and works its way up. However, if
I enter something like the following:

"this is a test. There is a new
line between the words 'new' and 'line'"

I end up with a news post that looks like "this is a test. There is a
newline between the words 'new' and 'line'".

What is going on? You can play with the script yourself if that helps
any, i've created a copy for use by you guys at
http://www.cse.msu.edu/~meyerro3/google.php . Will post the source
codes on that page in a minute.


Gerard
Guest
 
Posts: n/a
#2: Oct 12 '05

re: Text Area Forms and How Data is Stored


There's this which could help you get what u want.
WYSIWYG....http://www.htmlarea.com/directory/Detailed/117.html

Rgds,
Gerard

Zilla
Guest
 
Posts: n/a
#3: Oct 12 '05

re: Text Area Forms and How Data is Stored


Robizzle wrote:
[snip][color=blue]
> "this is a test. There is a new
> line between the words 'new' and 'line'"
>
> I end up with a news post that looks like "this is a test. There is a
> newline between the words 'new' and 'line'".[/color]
[snip]

My guess is that you don't convert newlines to <br>'s when you show the
posts. Html doesn't show a new line if there is just a newline. It needs
a <br> tag.

Take a look at this:

www.php.net/nl2br

Hope it helps.

Zilla.
Oli Filth
Guest
 
Posts: n/a
#4: Oct 12 '05

re: Text Area Forms and How Data is Stored


Zilla wrote:[color=blue]
> Robizzle wrote:
> [snip][color=green]
> > "this is a test. There is a new
> > line between the words 'new' and 'line'"
> >
> > I end up with a news post that looks like "this is a test. There is a
> > newline between the words 'new' and 'line'".[/color]
> [snip]
>
> My guess is that you don't convert newlines to <br>'s when you show the
> posts. Html doesn't show a new line if there is just a newline. It needs
> a <br> tag.
>
> Take a look at this:
>
> www.php.net/nl2br
>
> Hope it helps.
>[/color]

If you want to be HTML 4.01 compliant, use:

str_replace("\n", "<BR>", $str);

instead.

--
Oli

Robizzle
Guest
 
Posts: n/a
#5: Oct 12 '05

re: Text Area Forms and How Data is Stored


I'm sure there is a much easier solution to this than buying that for
$199. I didn't notice this before i posted but as i'm watching the
readers try to test posts on my page, I can see that the new lines are
getting registered and they are saved in the news.file.*.txt files.

It must just be an html issue at this point. I found if I add a <pre>
tag before the body section it will work, however that changes the font
and disables some CSS stuff. Anyone know of a way to make any new line
that apprears in an html document to come thru other than pre?

Or i'd guess my other solution would be to parse the $_POST["body"]
with a fairly simple function and replace all of the new line
characters with a <br> tag. If I do go this route, what would a new
line character ==?

Robizzle
Guest
 
Posts: n/a
#6: Oct 12 '05

re: Text Area Forms and How Data is Stored


Thanks Zilla and Oli!

Iván Sánchez Ortega
Guest
 
Posts: n/a
#7: Oct 12 '05

re: Text Area Forms and How Data is Stored


Robizzle wrote:
[color=blue]
> I end up with a news post that looks like "this is a test. There is a
> newline between the words 'new' and 'line'".[/color]

There *is* a newline character, but there is not a HTML line break
("<br/>"). Have a look at the nl2br function.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-arroba-escomposlinux-punto-org

You will be advanced socially, without any special effort on your part.

Oli Filth
Guest
 
Posts: n/a
#8: Oct 12 '05

re: Text Area Forms and How Data is Stored


Iván Sánchez Ortega said the following on 12/10/2005 15:24:[color=blue]
> Robizzle wrote:
>
>[color=green]
>>I end up with a news post that looks like "this is a test. There is a
>>newline between the words 'new' and 'line'".[/color]
>
>
> There *is* a newline character, but there is not a HTML line break
> ("<br/>").[/color]
^
^
Note: This is *not* an HTML line-break.


--
Oli
Iván Sánchez Ortega
Guest
 
Posts: n/a
#9: Oct 12 '05

re: Text Area Forms and How Data is Stored


Oli Filth wrote:
[color=blue][color=green]
>> There *is* a newline character, but there is not a HTML line break
>> ("<br/>").[/color]
> ^
> ^
> Note: This is *not* an HTML line-break.[/color]

Right, that's an *X*HTML line break. Lately I'm trying to make things
XHTML-compliant...

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-arroba-escomposlinux-punto-org

Signature has caused an exception 0E in register 0x4d6f7a333a333120
Geoff Berrow
Guest
 
Posts: n/a
#10: Oct 12 '05

re: Text Area Forms and How Data is Stored


I noticed that Message-ID: <0rvv13-rm8.ln1@blackspark.escomposlinux.org>
from Iván Sánchez Ortega
<ivansanchez[-@rroba]-escomposlinux.{[-punto-]{.org> contained the
following:
[color=blue][color=green][color=darkred]
>>> ("<br/>").[/color]
>> ^
>> ^
>> Note: This is *not* an HTML line-break.[/color]
>
>Right, that's an *X*HTML line break. Lately I'm trying to make things
>XHTML-compliant...[/color]

He he, still not right...

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Oli Filth
Guest
 
Posts: n/a
#11: Oct 12 '05

re: Text Area Forms and How Data is Stored


Geoff Berrow said the following on 12/10/2005 19:24:[color=blue]
> I noticed that Message-ID: <0rvv13-rm8.ln1@blackspark.escomposlinux.org>
> from Iván Sánchez Ortega
> <ivansanchez[-@rroba]-escomposlinux.{[-punto-]{.org> contained the
> following:
>
>[color=green][color=darkred]
>>>>("<br/>").
>>>
>>> ^
>>> ^
>>>Note: This is *not* an HTML line-break.[/color]
>>
>>Right, that's an *X*HTML line break. Lately I'm trying to make things
>>XHTML-compliant...[/color]
>
>
> He he, still not right...[/color]

He is right ;). <br/> is a valid XHTML empty element; however due to
some back-compatibility issues, it's always recommended to include a
space, i.e. <br />.


--
Oli
Iván Sánchez Ortega
Guest
 
Posts: n/a
#12: Oct 12 '05

re: Text Area Forms and How Data is Stored


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oli Filth wrote:
[color=blue]
> He is right ;). <br/> is a valid XHTML empty element; however due to
> some back-compatibility issues, it's always recommended to include a
> space, i.e. <br />.[/color]

http://www.w3.org/TR/xhtml1/#h-4.6
http://www.w3.org/TR/xhtml1/#guidelines

:-)

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez-arroba-mirame-punto-net

You prefer the company of the opposite sex, but are well liked by your own.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDTXH93jcQ2mg3Pc8RAmE1AJ4s5ykP7wEBdsLPlKM0Q6 YbSs46GQCZAZjb
MKcoDa6GAFDMRcBhihE9rEU=
=e/ob
-----END PGP SIGNATURE-----
Closed Thread