Upoading text for a web page. Best option...

strangedarstrangedar Senior MemberThe Royal RAM
I want to give my users the ability to upload poetry to my server to be displayed in my website but not sure which way to go about it...

I was considering either just having it so that they upload a .txt or .doc file to the server which i would format later and add to the poetry section in a .php page (I would probably have the upload form save all the required info in the database ready for when i format).

or

have the user copy and paste their poem into a text field which sends the text staright into the database which would mean I need a page to display it im guessing i can just load all the info into one page and stuff so pages wont need to be created :confused:. To do it this way the user would be able to format his/her own poem and it needs to stay thayt way when its displayed in its own page...

help :confused: what should i do... If i've confused you just ask and ill try and explain it better...
strangedarknesssig.jpg
sebastianastill.co.uk - My Portfolio

Comments

  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    Best option (IMHO):
    Create a database with fields for stuff like the username, title and content.
    Make a PHP script that will gather the information from the user and process it before putting it in the database.
    Make a simple listing script to show all the poetry or whatever.
    Make a script that obtains data from the database and spits out the HTML needed to view the article.

    Basically, if your table has an ID field, you could just grab the id and something like the title from your DB and use them in your artcles list.
    Each article would have a link that's something like http://www.yoursite.com/poetry.php?pid=1 where the pid is the articles ID.
    When you click the link, it sends you to the article viewing page which looks for the pid value, runs a query like:
    $var = mysql_query("SELECT * FROM poetry WHERE id = 1");
    
    And then you have all the data in your var, ready for use.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
  • strangedarstrangedar Senior Member The Royal RAM
    ok but what about keeping the poem in its original format? I can keep the line breaks and paragraphs by using something like \r ?
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
  • strangedarstrangedar Senior Member The Royal RAM
    Should the field type for the poem's content be TEXT(65535chars), MEDIUMTEXT(16777215) or LONGTEXT(4294967295)?
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
  • NuvoNuvo Forum Leader VPS - Virtual Prince of the Server
    For keeping line breaks, you'd just need to make the script look through the content for instances of \n and change them to <br> or <br /> depending on what version of HTML you're using.
    You can do this easily like so:
    /* say you have the var $data and your content is in it... */
    $data = str_replace('\n','<br />', $data);
    
    \n is the standard linebreak for plain text documents and for stuff put into a text field in a form.
    The field type is up to you.
    If you intend to have articles which are too long to fit into a standard text field, you'd have to use one of the larger options.
    PHP, CSS, XHTML, Delphi, Ruby on Rails & more.
    Current project: CMS Object.
    Most recent change: Theme support is up and running... So long as I use my theme resource loaders instead of that in the Rails plug-in.
    Release date: NEVER!!!
  • strangedarstrangedar Senior Member The Royal RAM
    ok, thanks nuvo! :D
    strangedarknesssig.jpg
    sebastianastill.co.uk - My Portfolio
Sign In or Register to comment.