#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Huntsville, AL, US
    Posts
    7
    Rep Power
    0
    Greetings to all,

    I'm trying to build a program allows users to hit the page and "build their own press release". It's amazing how many small businesses don't know how to do this already. In any case, the program would take this input and format a HTML file which could then be either sent to the user, or formatted to my press release format and saved as a HTML file on my site.

    I think everything is working great, EXCEPT the textfield. How do you take text input from a user by way of textfield, and preserve the carriage returns <BR> and paragraph markers <p> to fput correctly into the html file?

    Thanks in advance for the help,

    Wayne Hunt
    wayne@amiga.org
  2. #2
  3. No Profile Picture
    ledjon
    Guest
    Devshed Newbie (0 - 499 posts)
    First of all, forget about <p>'s. They're a pain the but and always mess things up. Besides, when somebody is typing in the info, they don't specify if they want 2 <br>'s or 1 <p></p>. The best thing to do (I've done this before.. it works great) is to just replace every n with a <BR>:
    ############
    $string = ereg_replace( "n", "<br>n", $string );
    ############
    This way no matter how many times they hit enter, it put's a <BR> for it.

    [This message has been edited by ledjon (edited July 19, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Huntsville, AL, US
    Posts
    7
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by ledjon:
    The best thing to do (I've done this before.. it works great) is to just replace every n with a <BR>:
    ############
    $string = ereg_replace( "n", "<br>n", $string );
    ############
    This way no matter how many times they hit enter, it put's a <BR> for it.
    [/quote]Thanks a million, I'll give that a try. Being just on the outer edge of "newbie-ism" with PHP, ereg_replace is new to me.

    Thanks,

    Wayne Hunt
    Amiga.org
  6. #4
  7. No Profile Picture
    ledjon
    Guest
    Devshed Newbie (0 - 499 posts)
    heh, I remember when I started PHP I searched high and low for a function that did that. (I come from a perl background, so I expected something like "s/string/replace string/i"). Man was I happy when I found it .
    ###
    $string = ereg_replace( "'", "'", $string );
    ###
    This is a very important function for adding info to a database.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    You can also just use the nl2br() function, like:

    $string = nl2br($string);

    Chris
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Huntsville, AL, US
    Posts
    7
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Chris Pickett:
    You can also just use the nl2br() function, like:

    $string = nl2br($string);

    Chris
    [/quote]There sure are a lot of functions that I've never seen/heard of

    Question: Which textfield wordwrap should I use? None? Virtual? Physical?

    Thanks,

    Wayne




    [This message has been edited by Wayne Hunt (edited July 19, 2000).]
  12. #7
  13. No Profile Picture
    ledjon
    Guest
    Devshed Newbie (0 - 499 posts)
    I'd just leave the wordwrap part off all together. Netscape may get a scroll bar at the bottom, but I don't think it matters what you have it as, you'll still get the scroll bar.

    >$string = nl2br($string);

    Heh, perl programers don't believe in taking the easy way out! You don't even have to parse the form data that was sent in PHP!

    I've actually integrated perl scripts so that a modification to the parsing routine was crucial to the script. That means I can't re-create the script the same way in PHP because of it's "ease". Oh well, I do like PHP!

Similar Threads

  1. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 10:56 AM
  2. mgetty+sendfax on RH9
    By ayrin in forum Linux Help
    Replies: 0
    Last Post: January 31st, 2004, 02:11 AM
  3. Advice on reversing order of characters within a string?
    By FriscoKid in forum C Programming
    Replies: 5
    Last Post: November 13th, 2003, 08:13 AM
  4. finding max string length if more than 2 elements
    By sri197 in forum XML Programming
    Replies: 1
    Last Post: November 7th, 2003, 06:17 PM
  5. Perl string handling
    By arsenio in forum Perl Programming
    Replies: 4
    Last Post: October 22nd, 2003, 11:43 AM

IMN logo majestic logo threadwatch logo seochat tools logo