NewB Q again.
I'm in the process of writing a highly customised web board
(discussion/forum whatever you want to call it),
I need to know how to get it to process the input taken from a form and keep
it in the spacing set out by the user.
I can get it to insert into the mySQL database, pull it out again and show
it,
I can even edit it, which I thought was pretty good considering I am a newB
to both PHP and mySQL.
I just need to display the way the user enters it rather than with no line
spacing or anything. Also how would I do a spell check and preview?
thanks
- inpho -
> I just need to display the way the user enters it rather than with no
> line spacing or anything.
<pre>
This
text will
be d i s p lay ed
just like
that in the browser.
</pre>
> Also how would I do a spell check and
The easy way is to call ispell or aspell (whichever is available and
better for you) on the server. The hard way is to code one yourself.
> preview?
Submit the form to the preview script, make it display the same HTML and
data which would be shown if displaying a normal entry and beneath (or
above) the same form as at entry creation, with the already entered data
filled in. This involves more cut'n'paste than coding.
--
Some people say that dying is hazardous for one's health.
Others say that nothing can travel faster than light.
I wonder what the logical connection between these statements is.
> The easy way is to call ispell or aspell (whichever is available and
I will look these up on php.net, thanks.
> > preview?
>
> Submit the form to the preview script, make it display the same HTML and
> data which would be shown if displaying a normal entry and beneath (or
> above) the same form as at entry creation, with the already entered data
> filled in. This involves more cut'n'paste than coding.
ok, thanks
- inpho -
>> <pre>
>
> Umm, that may very well work, but it puts it in that really crappy
> font....
So what? I use a text-mode browser, so I don't care about fonts. But if
you need it, you can use CSS to change the font. Something like:
pre
{
font-family: sans-serif;
// Check http://www.w3.org/TR/REC-CSS1#font-family for more.
}
However, <pre> (and everything which works equivalently) only makes sense
with fonts like Courier.
>> The easy way is to call ispell or aspell
>
> I will look these up on php.net, thanks.
Use the pspell functions with aspell, as described in
http://www.php.net/manual/en/ref.pspell.php .
HTML should be used to markup the structure of a document, using <pre>
in this instance does not seem to properly reflect the structure, as
it's being used purely for its presentational effects.
I think in the case of a message board paragraphs (<p>) should do fine.
If a user wants to use preformatted text, let them use <pre> within
their post (or use UBB code, or something similar).
However, if you (OP) do decide to let users insert markup into their
posts, you need to be very careful. If someone doesn't close a <pre>,
the rest of the page may end up as preformatted text, a user might try
to use some vicious javascript, etc.
Personally, I probably try to enclose every set of two consecutive line
breaks with <p> and </p>. If you are really stuck on the idea of
preformatted text, I would keep to paragraphs and use a stylesheet
declration such as p { white-space : pre; }.
HTH
>>>> <pre>
>
> HTML should be used to markup the structure of a document,
Full ACK.
> using <pre> in this instance does not seem to properly reflect the
> structure,
I have interpreted the OP's intent as displaying preformatted text where
preformatted text is meant. However, if it's only a display thing, CSS is
indeed better.
2nd - We are talking about a bunch of plankton here, the type of people who
wouldn't know what html was if the survival of the entire human race
depended on it (a highly unlikely situation... lol). All our users want to
do, is type a message in, post it to the board and have it display with the
appropriate gaps and line breaks.
thanks guys for your help so far.
I've been reading SAMS Teach yourself PHP in 24 hours can any one sugguest
some better books?
Thanks again
- inpho -
> First of all, I don't really care about who uses what browser,
Good attitude. There is no excuse for people who use non-compliant
browsers and their complaints should be forwarded to /dev/null, so long as
your page is standard-compliant (and makes sense).
> this webboard is being hosted on a Windows 2000 Terminal server, the
> only possible way for people to see it is through the terminal session
> internet browser, which is IE5.
*ROFL* Sorry, but I won't ever take M$ technology seriously.
> 2nd - We are talking about a bunch of plankton here, the type of people
> who wouldn't know what html was if the survival of the entire human race
> depended on it (a highly unlikely situation... lol). All our users want
> to do, is type a message in, post it to the board and have it display
> with the appropriate gaps and line breaks.
However, _you_, the programmer, should care a lot about your code. The
human is distinct from the animal by his work. Care about your work if you
care about yourself.
> I've been reading SAMS Teach yourself PHP in 24 hours can any one
> sugguest some better books?
Once you've mastered the basics of the syntax, forget all books, go
directly to http://php.net/manual/en/ and read the stuff there, including
the users' comments. Then try whatever you read on your development
machine. This way you'll learn more PHP than you could ever learn from a
book (unless it were a copy of the PHP manual ;) ).
eregi_replace("\n", "<br>", $message);
should do the trick. you should still make sure no HTML gets in your
messages...one of the heard might get smart...doubtful, but possible
nonetheless.
> eregi_replace("\n", "<br>", $message);
php already has a function nl2br:
http://www.php.net/nl2br
even uses <br /> for XHTML compliance.
> should do the trick. you should still make sure no HTML gets in your
> messages...one of the heard might get smart...doubtful, but possible
> nonetheless.
Strip Tags will do that for you ... it's rarely a bad idea:
http://www.php.net/strip_tags
regards,
reggie
> Strip Tags will do that for you ... it's rarely a bad idea:
This depends. Some people use HTML-like tags while writing, e. g. to
indicate <irony>serious</irony> text or as mentioned in the jargon file
[1] etc. Imho it is therefore better to use htmlentities (which is a good
idea anyway before sending anything to a HTML UA) rather than strip_tags.
[1]: http://www.tuxedo.org/jargon/html/Hacker-Writing-Style.html
> > eregi_replace("\n", "<br>", $message);
>
> php already has a function nl2br:
> http://www.php.net/nl2br
6 to one, half dozen to another...