Welcome, Guest
  • Author Topic: Submit forms and text/string processing  (Read 5178 times)

    Barrett

    • Server what's that
    • *
    • Posts: 15
      • View Profile
      • Email
    Submit forms and text/string processing
    « on: 06/07/02, 10:59 »
    If you have a "post" page, and it involves a large textbox like this one where an almost unlimited amount of text can be entered, how can you write it to a file without appending it to a string and getting all that funny .php hash on every special character and submitting it to another page? How does this site do it? Do I need to write a pearl module that formatts my text for me so it includes linefeeds and tab characters?
    A wise man once said: 'Blearg b-scrub'

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Submit forms and text/string processing
    « Reply #1 on: 06/07/02, 16:20 »
    You have to send the data via "POST" - instead of attaching it onto the end of the query string.  The limit to the amount you can send is basically unlimited.

    The line breaks should be preserved.

    If they are not make sure your not including anything like:

    $Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);

    (That line would strip out all line breaks - if it was included).
    Flash-DB

    Barrett

    • Server what's that
    • *
    • Posts: 15
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #2 on: 06/10/02, 11:45 »
    I'm not sure sure how this topic ended up here but oh well. Its a submit form that uses "preview.php" to write the variables like "TextTitle" and "TextEntry". It always puts slashes before the ['] and [\] characters and strips the tab and linefeed characters too. Would you like some source? I think what I'm doing is very elementary, so I haven't posted any yet.
    A wise man once said: 'Blearg b-scrub'

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Submit forms and text/string processing
    « Reply #3 on: 06/10/02, 12:25 »
    Ok - The slashes are automatically added so that when the data is inserted into a database - it does not mess things up (The ' and \ characters can potentially do that to any database)

    It is fairly easy to get rid of though.  Just pass your data through a stripslashes function and that will take care of it.

    For example:

    $Text = stripslashes($Text);

    (http://www.php.net/manual/en/function.stripslashes.php)

    The linefeed / linebreak characters  \n, \r (you can't see these but their their) - will be striped if you are striping other characters from the text - but they will not be striped if you are not.

    A function like
    ereg_replace("[^A-Za-z0-9 ]", "", $Name); - will strip them out along with all the other characters - so you may want to get rid of the lines that look similiar.


    Flash-DB

    Barrett

    • Server what's that
    • *
    • Posts: 15
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #4 on: 06/10/02, 15:36 »
    Heh sorry about being a stupid newb. Yeah, the stripslashes() was what I was looking for  ;D.  I might be getting my linefeed chars stripped cause i'm using a CSS text-align: justify; which would fuigure cause life isn't complete unless I make myself look like a complete l4m0r newb. One more thing, who's idea was it to have a Tony Hawk icon in such a professional forum? It's freakin radfaced!
    « Last Edit: 06/10/02, 15:37 by Barrett »
    A wise man once said: 'Blearg b-scrub'

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Submit forms and text/string processing
    « Reply #5 on: 06/10/02, 19:02 »
    Quote
    One more thing, who's idea was it to have a Tony Hawk icon in such a professional forum? It's freakin radfaced!


    - probably mine.  I'm not so much of computer dork lol.  well not so sure any more.

    here's an old site I ran:  http://www.coloradoboarders.com

    http://www.coloradoboarders.com/images/Hood9_6_00/HoodRiders.htm

    (used to snowboard/skate quite a bit - going to try to get way back into it next year).

    Had to keep a little taste of home here for me..

    Got any other idea's for images - I'll add um.
    Flash-DB

    Barrett

    • Server what's that
    • *
    • Posts: 15
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #6 on: 06/10/02, 20:40 »
    Wurd up holmes, board sports r0x0r! Heh my best friend is a freakin awesome skateboarder, were gonna make crazykiddwhoah!faced skate vids and such, thats kinda one of the parts the sites gonna be about. I'm tossing like all sorts of hip hop - old skool styles into it. I like that nice time delay pic. Heh I'm such a complete poser though, and my friend is always tellin stories bout little kids ranting about "can you do a 900? oh you suck!" and him bein like "step on the board baisch". Anyway, I'll have to send you the link when I finally get it running off my cable modem when I move here in like a month. It's gonna be so kewl.  PACE!! Thanx for all the help, you have no idea what I'm brewing here ;D.
    A wise man once said: 'Blearg b-scrub'

    Barrett

    • Server what's that
    • *
    • Posts: 15
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #7 on: 06/11/02, 14:42 »
    I got it working heh. When I tried to print the string it would omit all those characters, but somehow i was searching for the tab char in the php manual pdf i dled from php.net, and I came across strtok($string, "search chars"). I was gonna search for the chars and print them in the html <br> format, but strtok() did me one better. I could search for those chars and then insert <br> wherever it found the "\n" and "\r" characters.  Plus I could also include code so you could type %quote% and %/quote% and it would format the text quote style and I could edit out multiple enter pushing. Check this out [%(/)quote% must each be on thier own line]:


    <?php
       global $NewText;
           //start the token
       $tok = strtok($TextEntry, "\n\r");

       while($tok){

          //if the token yielded a linefeed or carriage return [hence "enter pusher"]
          if($tok == "\n\r"){
             //do strtok again to just skip over it, don't append it to $NewText
             strtok("\n\r");}

          //if the token yielded a %quote%, start "QuoteMode!" bum bum bum!
          if(strstr($tok, "%quote%")){
             //the skip to the next yield, we don't want to print %quote
             $tok = strtok("\n\r");
             //set up the font settings in html
             $NewText .= '<font color="orange"><i>';
             //run until you hit the %/quote%
             while(!strstr($tok, "%/quote%")){
                //append the contents to $NewText
                $NewText .= "$tok<br>";
                //NEXT!!
                $tok = strtok("\n\r");}
             //the loop exited, and $tok = "%/quote%", so skip so we don't print it
             $tok = strtok("\n\r");
             //end the text formatting
             $NewText .= '<br></i></font>';}

          //if it wasn't anything fancy, it was a regular new paragraph
          else{
             //append to $NewText, indent it with non-breaking spaces, add two lines
             $NewText .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tok<br><br>";
             //NEXT!
             $tok = strtok("\n\r");}
       }
       //There are no more tokens, so print the final result
       Print "$NewText";
    ?>
    A wise man once said: 'Blearg b-scrub'

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Submit forms and text/string processing
    « Reply #8 on: 06/11/02, 14:49 »
    Nice - still not sure exactly what your doing -

    But be sure to post the link when your done - looking forward to checkin it out.
    Flash-DB

    Greg Killam

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #9 on: 06/27/02, 22:11 »
     Hood Huh?  My backyard last night!  8) http://www.vroom360.com/hood/hood.jpg
    I'm a old schooler from the 80's...Still rid'in a 196 Nitro swallow tail  ;D
     I started ZigZag Hemp Snowboards way back, think my ex-aussie partner is still press'in boards???
     Ever in town again? Get a hold of me & I'll buy a couple pitchers at "TheRat!"

     Cheers...ziggy

    « Last Edit: 06/27/02, 22:14 by Greg Killam »

    Flash-db

    • Administrator
    • Systems Administrator
    • *****
    • Posts: 1876
      • View Profile
      • Flash-db.com
    Re:Submit forms and text/string processing
    « Reply #10 on: 06/27/02, 23:31 »
    Wow - Nice.

    Got a Nitro 2 from about 2 years ago now.

    Damm - sounds like a good offer (pitchers at the Rat).

    How'd you find your way to this message board.

    Also - happen to know Steve sherick or any of the other counselors at High Cascade.  I'm really hoping I can make it out their this summer (doubtful) - Getting sick of all the fires and 100 degree temps in Colorado.


    Flash-DB

    Greg Killam

    • Server what's that
    • *
    • Posts: 14
      • View Profile
      • Email
    Re:Submit forms and text/string processing
    « Reply #11 on: 06/28/02, 11:48 »
     Howzit?  8)  

    I ended up here from your Flash Form tut at FK.  
    I'm just starting to play w/Flash & PHP...cool stuff!   Its time to add some Flash interfaces to some PHP apps I have.

    Saw Hood & that you ride...thought I'd say Hey!   ;D

    Looks like you have plenty here for me to study up on, I'm sure I'll be asking some questions too!


    Steve Scherik sounds familiar? A good buddy of mine runs Windells, I'm sure I could get you hooked up somehow? Could probably get you some side PHP work too.

    Cheers...ziggy