SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everyone,

    I've been loitering with intent for the last couple of weeks and I've found some great stuff on these forums, it looks like a great place to exchange information.

    I've recently been given the role as the IT administrator for our European corporate intranet and one of the first projects which I'm undertaking is the publishing of a new Corporate Mission Statement.

    The idea is that the statement will be published in it's first draft form in week or so. Employees will be able to comment on the various pages via a feedback form and these comments will appear at the base of the page.

    I've created an SQL database with fields for ID (auto incrementing), comment (text), poster (text) and date (date). I can pull the data from this database into the appropriate sections of the site using php when needed and I can write to the datebase using mysql. I can't seem to get my form working to put date into the database.

    I would like to have a page that is dedicated to this task (so I can maybe implement it in a popup window - haven't decided yet), with two "textarea" boxes for the input of 'comment' and 'poster' and the form to complete the ID and date. When the submit button is clicked, the page should update the database and then take the user back to the Mission Statement page and refresh it to update the comments.

    Sorry that was a bit long winded but this is my first outing into the world of php.

    TIA

    ------------------
    Check out my PC specs: here
    e-mail me: mincer2001@hotmail.com
    Last edited by Mincer; Mar 1, 2001 at 16:25.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The solution is even easier. No need to handle the date in the form.

    Create a column in your table of type DATE or DATETIME and give it the default value of NOW() . This means that everytime you do an INSERT into the table (ie; when your PHP script is processing the data returned from the form) the date column will be set to the current date. See http://www.mysql.com/doc/D/A/DATETIME.html for details of DATE type.

    When you are retrieving the info from the dbase you can use mySQLs date formating functions to format the date into a human(TM) friendly string. See http://www.mysql.com/doc/D/a/Date_an...functions.html

  3. #3
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    freakysid,

    Thanks for the reply, I'll look in to that now() idea, looks useful.

    However, I'm more of a duffer with forms and php than you'd imagine.

    Here is my first go at the form but what goes in the <php> bit??

    <FORM ACTION="<?php *** what goes here?? *** ?>" METHOD=POST>
    <P>Please type your comment hereBR>
    <TEXTAREA NAME="comment_text" ROWS=10 COLS=70 WRAP></TEXTAREA>
    <BR>
    <INPUT TYPE=SUBMIT NAME="submit_comment" VALUE="SUBMIT">
    </FORM>

    This is the code to connect to the database (i think)

    // Connect to the database server

    $dbcnx = @mysql_connect("localhost", "root", "");
    if (!$dbcnx) {
    echo( "<P>Unable to connect to the database server at this time.</P>" );
    exit();
    }

    This is the database selection....

    if (! @mysql_select_db("mission_statement_comments") ) {
    echo( "<P>Unable to locate the database at this time.</P>" );
    exit();
    }

    but where do these statements go in the overall scheme of things, and what php do I use to actually add the comments to the database?

    TIA

  4. #4
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HELP

  5. #5
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorted


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •