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. Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/ 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? Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644683 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.??? Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644684 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)... Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644686 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? Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644687 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'])); Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644688 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. Link to comment https://forums.phpfreaks.com/topic/124795-insert-articlepage1-and-view-article-with-html-formattingpage2/#findComment-644691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.