Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Web board in PHP & mySQL - NewB Q

1 view
Skip to first unread message

inpho

unread,
Oct 3, 2002, 11:29:47 AM10/3/02
to
Hey all,

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 -


Ewgenij Starostin

unread,
Oct 3, 2002, 1:39:53 PM10/3/02
to
inpho wrote:

> 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.

inpho

unread,
Oct 3, 2002, 1:54:24 PM10/3/02
to
> <pre>
Umm, that may very well work, but it puts it in that really crappy font....

> 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 -


Ewgenij Starostin

unread,
Oct 3, 2002, 2:37:32 PM10/3/02
to
inpho wrote:

>> <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 .

Steven Vasilogianis

unread,
Oct 3, 2002, 4:55:24 PM10/3/02
to
In article <363ina...@linsrv.local>, ewge...@gmx.de says...

> inpho wrote:
>
> >> <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.

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

Ewgenij Starostin

unread,
Oct 3, 2002, 5:22:10 PM10/3/02
to
Steven Vasilogianis wrote:

>>>> <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.

inpho

unread,
Oct 4, 2002, 7:18:27 AM10/4/02
to
First of all, I don't really care about who uses what browser, 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. The board is only for our registered clients, all of whom are using
our custom designed thin client networks, so we know what browser they are
using.

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 -


Ewgenij Starostin

unread,
Oct 4, 2002, 7:34:03 AM10/4/02
to
inpho wrote:

> 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 ;) ).

r.

unread,
Oct 5, 2002, 1:22:37 AM10/5/02
to
In article <LnZm9.24099$kd3....@news-server.bigpond.net.au>,
"inpho" <inp...@gmx.net> wrote:

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.

reggie

unread,
Oct 5, 2002, 8:05:31 PM10/5/02
to

"r." <n...@randys.org.dev.null> wrote in message
news:no-A0DA8E.22...@newssvr14-ext.news.prodigy.com...

> 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


Ewgenij Starostin

unread,
Oct 6, 2002, 8:00:46 AM10/6/02
to
reggie wrote:

> 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

r.

unread,
Oct 7, 2002, 1:39:51 AM10/7/02
to
In article <f7Ln9.459535$v53.20...@news3.calgary.shaw.ca>,
"reggie" <reggie...@reggieband.com> wrote:

> > eregi_replace("\n", "<br>", $message);
>
> php already has a function nl2br:
> http://www.php.net/nl2br

6 to one, half dozen to another...

0 new messages