Textarea handling in php ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony B

    #1

    Textarea handling in php ?

    I'm learning a little about using forms in php to enter data, and have a
    couple of questions re textarea.
    At the moment I just use "addslashes () to process the value from textarea so
    that punctuation is escaped, and write this into a table.
    When the text wraps in the text box I get a new line in the value returned,
    as well as new lines that I enter manually.
    Is it possible to remove the wrap new line but keep the user entered new
    line ?



  • Jerry Stuckle

    #2
    Re: Textarea handling in php ?

    Tony B wrote:
    I'm learning a little about using forms in php to enter data, and have a
    couple of questions re textarea.
    At the moment I just use "addslashes () to process the value from textarea so
    that punctuation is escaped, and write this into a table.
    When the text wraps in the text box I get a new line in the value returned,
    as well as new lines that I enter manually.
    Is it possible to remove the wrap new line but keep the user entered new
    line ?
    >
    >
    >
    >
    First of all, you shouldn't be using addslashes(). If you're writing to
    a MySQL database, you should be using mysql_real_esca pe_string() instead.

    As for the new lines - how is your code to know which are inserted by
    the textarea and which are inserted by the user? Better to use send the
    data correctly in the first place. See the WRAP attribute of a textarea .

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Captain Paralytic

      #3
      Re: Textarea handling in php ?

      On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      Tony B wrote:
      I'm learning a little about using forms in php to enter data, and have a
      As for the new lines - how is your code to know which are inserted by
      the textarea and which are inserted by the user? Better to use send the
      data correctly in the first place. See the WRAP attribute of a textarea .
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===
      Surely that should have been: "Better to use send the data correctly
      in the first place. See the WRAP attribute of a textarea. But this
      has nothing to do with php.

      ;-)

      Comment

      • Jerry Stuckle

        #4
        Re: Textarea handling in php ?

        Captain Paralytic wrote:
        On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        >Tony B wrote:
        >>I'm learning a little about using forms in php to enter data, and have a
        >As for the new lines - how is your code to know which are inserted by
        >the textarea and which are inserted by the user? Better to use send the
        >data correctly in the first place. See the WRAP attribute of a textarea .
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstuck...@attg lobal.net
        >============== ====
        >
        Surely that should have been: "Better to use send the data correctly
        in the first place. See the WRAP attribute of a textarea. But this
        has nothing to do with php.
        >
        ;-)
        >
        True. :-)

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Mason Barge

          #5
          Re: Textarea handling in php ?


          "Tony B" <tagb61@yahoo.c o.ukwrote in message
          news:aeNDj.9850 9$FE.91698@fe05 .news.easynews. com...
          I'm learning a little about using forms in php to enter data, and have a
          couple of questions re textarea.
          At the moment I just use "addslashes () to process the value from textarea
          so that punctuation is escaped, and write this into a table.
          When the text wraps in the text box I get a new line in the value
          returned, as well as new lines that I enter manually.
          Is it possible to remove the wrap new line but keep the user entered new
          line ?
          >
          >
          IIRD, "wrap" is not an attribute of textarea in any version of html or xhtml
          I've used - it's a proprietary attribute of Netscape/IE. You're just asking
          for cross-browser trouble if you use it. Check out the white-space attribute
          of CSS.

          If this is for web display and you need to generate a hard new line in html,
          use <br />.

          Comment

          • Tony B

            #6
            Re: Textarea handling in php ?

            First of all, you shouldn't be using addslashes(). If you're writing to a
            MySQL database, you should be using mysql_real_esca pe_string() instead.
            >
            As for the new lines - how is your code to know which are inserted by the
            textarea and which are inserted by the user? Better to use send the data
            correctly in the first place. See the WRAP attribute of a textarea .
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===
            Thanks for the pointer. I wasn't worried about sql injection as these are
            not on public pages, but worth knowing for the future.
            The wrap attribute does what I need.
            Thanks
            Tony


            Comment

            • Jerry Stuckle

              #7
              Re: Textarea handling in php ?

              Tony B wrote:
              >First of all, you shouldn't be using addslashes(). If you're writing to a
              >MySQL database, you should be using mysql_real_esca pe_string() instead.
              >>
              >As for the new lines - how is your code to know which are inserted by the
              >textarea and which are inserted by the user? Better to use send the data
              >correctly in the first place. See the WRAP attribute of a textarea .
              >>
              >--
              >============== ====
              >Remove the "x" from my email address
              >Jerry Stuckle
              >JDS Computer Training Corp.
              >jstucklex@attgl obal.net
              >============== ====
              Thanks for the pointer. I wasn't worried about sql injection as these are
              not on public pages, but worth knowing for the future.
              The wrap attribute does what I need.
              Thanks
              Tony
              >
              >
              >
              You need to be worried about SQL injection, especially on internal
              sites. More damage can be done by disgruntled employees than hackers.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • Tony B

                #8
                Re: Textarea handling in php ?


                "Mason Barge" <masonbarge@com cast.netwrote in message
                news:V6ednVp9S-mLKULanZ2dnUVZ_ qCunZ2d@comcast .com...
                >
                "Tony B" <tagb61@yahoo.c o.ukwrote in message
                news:aeNDj.9850 9$FE.91698@fe05 .news.easynews. com...
                >I'm learning a little about using forms in php to enter data, and have a
                >couple of questions re textarea.
                >At the moment I just use "addslashes () to process the value from textarea
                >so that punctuation is escaped, and write this into a table.
                >When the text wraps in the text box I get a new line in the value
                >returned, as well as new lines that I enter manually.
                >Is it possible to remove the wrap new line but keep the user entered new
                >line ?
                >>
                >>
                >
                IIRD, "wrap" is not an attribute of textarea in any version of html or
                xhtml I've used - it's a proprietary attribute of Netscape/IE. You're
                just asking for cross-browser trouble if you use it. Check out the
                white-space attribute of CSS.
                >
                If this is for web display and you need to generate a hard new line in
                html, use <br />.
                What I want is textarea not to insert line breaks just because the user
                enters a line that is longer than the number of columns. Wrap can do this in
                IE/FF/Opera etc.
                I cannot see how css can alter the behaviour of textarea as to whether it
                inserts hard line breaks when a line wraps in the textarea box ?


                Comment

                • Captain Paralytic

                  #9
                  Re: Textarea handling in php ?

                  On 19 Mar, 09:31, "Tony B" <to...@imagepro c.comwrote:
                  I cannot see how css can alter the behaviour of textarea as to whether it
                  inserts hard line breaks when a line wraps in the textarea box ?
                  Cannot see or haven't tried to?
                  I put
                  css white-space
                  into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
                  explanation.

                  Comment

                  • Captain Paralytic

                    #10
                    Re: Textarea handling in php ?

                    On 19 Mar, 09:57, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                    On 19 Mar, 09:31, "Tony B" <to...@imagepro c.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it
                    inserts hard line breaks when a line wraps in the textarea box ?
                    >
                    Cannot see or haven't tried to?
                    I put
                    css white-space
                    into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
                    explanation.
                    And this explains even better:

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Textarea handling in php ?

                      Captain Paralytic wrote:
                      On 19 Mar, 09:31, "Tony B" <to...@imagepro c.comwrote:
                      >I cannot see how css can alter the behaviour of textarea as to whether it
                      >inserts hard line breaks when a line wraps in the textarea box ?
                      Cannot see or haven't tried to?
                      I put
                      css white-space
                      into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
                      explanation.
                      >
                      That doesn't stop the insertion of a line break when the text wraps. It
                      just controls whether the line wraps or not.

                      No, "wrap" is not an HTML attribute, but it is supported every recent
                      browser I've tried.

                      And for Tony, <br /is not a valid html break.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: Textarea handling in php ?

                        Captain Paralytic wrote:
                        On 19 Mar, 09:57, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                        >On 19 Mar, 09:31, "Tony B" <to...@imagepro c.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it
                        >>inserts hard line breaks when a line wraps in the textarea box ?
                        >Cannot see or haven't tried to?
                        >I put
                        >css white-space
                        >into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
                        >explanation.
                        >
                        And this explains even better:

                        >
                        Ah, yes - now I see...

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Captain Paralytic

                          #13
                          Re: Textarea handling in php ?

                          On 19 Mar, 12:01, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                          Captain Paralytic wrote:
                          On 19 Mar, 09:57, Captain Paralytic <paul_laut...@y ahoo.comwrote:
                          On 19 Mar, 09:31, "Tony B" <to...@imagepro c.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it
                          >inserts hard line breaks when a line wraps in the textarea box ?
                          Cannot see or haven't tried to?
                          I put
                          css white-space
                          into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
                          explanation.
                          >>
                          Ah, yes - now I see...
                          Yes, as has been metioned in recent threads, w3schools is good for an
                          introduction, but it doesn't always tell one the whole truth.
                          I do think that this particular w3.org section is one of their clearer
                          ones.

                          Comment

                          • Toby A Inkster

                            #14
                            Re: Textarea handling in php ?

                            Jerry Stuckle wrote:
                            And for Tony, <br /is not a valid html break.
                            "<br/>" is valid in HTML. It just doesn't mean what people think it means.
                            It is equivalent to "<br>&gt;" because of SGML shorttag rules.

                            --
                            Toby A Inkster BSc (Hons) ARCS
                            [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                            [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 13:37.]

                            The Semantic Web

                            Comment

                            • Toby A Inkster

                              #15
                              Re: Textarea handling in php ?

                              Captain Paralytic wrote:
                              Yes, as has been metioned in recent threads, w3schools is good for an
                              introduction, but it doesn't always tell one the whole truth. I do think
                              that this particular w3.org section is one of their clearer ones.
                              w3.org and w3schools.com are entirely different websites. Do not get them
                              mixed up.

                              w3.org is the World Wide Web Consortium (W3C), an organisation set up by
                              Sir Tim Berners-Lee to steer the development of the web, supported by many
                              academic organisations, browser makers and content producers. They have
                              been responsible for all HTML specifications since version 3.2, and for
                              CSS, the DOM, XML, SVG, RDF, SOAP and various other web-related
                              technologies. This responsibility for them has been informally delegated
                              to them by the IETF.

                              w3schools.com is a tutorial website owned by a small Norwegian company
                              called Refsnes Data. Although their tutorials are generally fairly good,
                              the company is in no way affiliated with the W3C, and their tutorials are
                              no more "official" than any turoial you or I could put together. Most of
                              their tutorials are aimed at helping your learn W3C standards, and other
                              web-related technologies.

                              --
                              Toby A Inkster BSc (Hons) ARCS
                              [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
                              [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 13:56.]

                              The Semantic Web

                              Comment

                              Working...