inquisitive Posted September 18, 2008 Share Posted September 18, 2008 I am setting up an article database where users can enter the text of their choice via <textarea> on an add_article.php page which is processed by a separate page...and then on yet another page you can view articles...What i want to know is how to make it so that users can enter their articles minus formatting in the previous mentioned. Pressing the enter key in the textarea box also need to be equivalent to a <br /> Then I want to echo this into the view_articles.php. All I need is the processing code to enter these articles in the way I desire. Quote Link to comment Share on other sites More sharing options...
dave_sticky Posted September 18, 2008 Share Posted September 18, 2008 If you want to get the text area output to have line breaks, you just use <?php $text = nl2br($_POST['your_textarea']); ?> The key-stroke "Enter" doesn't actually get lost, its just that HTML can't do anything with it, as it is passed as a \n. I don't really understand the rest of your post... No other formatting should be carried across in a text area... Unless you are talking about users adding their own HTML? Quote Link to comment Share on other sites More sharing options...
peranha Posted September 18, 2008 Share Posted September 18, 2008 Do you mean you want to use bbcode like when you reply to posts on this site where you have bold, italics, underline, etc.??? Quote Link to comment Share on other sites More sharing options...
inquisitive Posted September 18, 2008 Author Share Posted September 18, 2008 I was just talking about when it is output there are appropriate paragraph breaks...links appear as they should...lists appear as unordered lists...if the list thing is too difficult that is fine...the articles just need to look good (properly formatted) and be readable. Just curious what does it take to create an article submission program where you have the option to format it the way you like...kind of like emails and forums (like this one)... Quote Link to comment Share on other sites More sharing options...
dave_sticky Posted September 18, 2008 Share Posted September 18, 2008 Ah, well now you'll be talking about bbcode. The nl2br() function that I mentioned previously will paragraph your text properly (or at least, as the user enters it), but other formatting tends to be a lot more complicated. Creating something like this forum takes a lot of work. Why not just download an existing application - a blog would do the things that you are after, and probably be the most suitable - and use that instead? Quote Link to comment Share on other sites More sharing options...
inquisitive Posted September 18, 2008 Author Share Posted September 18, 2008 Possibly...how does that n12br function work if my code looks like this... $article = mysql_real_escape_string(stripslashes($_POST['article'])); Quote Link to comment Share on other sites More sharing options...
dave_sticky Posted September 18, 2008 Share Posted September 18, 2008 Should just be a case of: <?php $article = mysql_real_escape_string(stripslashes(nl2br($_POST['article']))); ?> Edit: By the way, I was just looking at php.net for mysql_real_escape_string() and I don't understand your use of it in this situation (possiblly because I can't see the rest of the code) but it seems a bit redundant here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.