Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2012
    Location
    Sweden
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Making a forum - need help with submit button (PhP)

    Hello there,

    I am making a website for my dad which should be music-inspired and in this website i would like to make a forum where people can post and reply what they think about his music etc.

    So far, i have done a mysql database called "forum" which includes 4 tables. First table: categories, Second table: posts, Third table: topics and Fourth table: users.

    Now i think it's time to begin with PhP and here's my idea of what should be included in my forum. First of all i want 2 buttons called "Create a thread" and "Create a category". Then, when you click at one of those buttons, let's say "Create a thread" button. I want it to appear 2 text-fields on your screen, one subject text-field and another text-field where the content should be. And then i want a "post"/"submit" button where you should be able to click when you want to post the thread you've typed in.

    Problem: Well, i know how to make <form></form>, make textfields and buttons in html and how to include php-files. But what i don't know are, when i press the "post" button, how do i save the thread? Because i don't want the thread or text to disappear when i close my browser, turn off the computer or log out from the website.

    I am quite new to this, i know my forum-plan could need some more work and my english aren't the best. But i love what i'm doing and i want to become better. Making websites are something i really would like to go on with in future. I really hope you guys can help me out! Cheers.

    Best regards: webjoker :)

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,453
    Thanks
    71
    Thanked 102 Times in 101 Posts
    You would have a function such as "newthread()". You could set it up like this.

    PHP Code:
    function newthread() {

    if (isset(
    $_POST['submit'])) {
    $title $_POST['title'];
    $message $_POST['content'];

    //Query to update database with new thread
    }
    else {
    //Show Form

    So it will default to show the form when they click new thread. Once submitted the query will update the database and save the new thread.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • Users who have thanked myfayt for this post:

    webjoker (01-02-2012)

  • #3
    New Coder
    Join Date
    Jan 2012
    Location
    Sweden
    Posts
    32
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by myfayt View Post
    You would have a function such as "newthread()". You could set it up like this.

    PHP Code:
    function newthread() {

    if (isset(
    $_POST['submit'])) {
    $title $_POST['title'];
    $message $_POST['content'];

    //Query to update database with new thread
    }
    else {
    //Show Form

    So it will default to show the form when they click new thread. Once submitted the query will update the database and save the new thread.
    Oh thank you very much! I really appreciate your help and i will try out something like you just showed me. Well thank you once again.

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,339
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    Easiest thing to do would be to download and install a forum such as phpbb.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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