...

View Full Version : Making a forum - need help with submit button (PhP)



webjoker
01-02-2012, 08:16 PM
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 :)

myfayt
01-02-2012, 08:31 PM
You would have a function such as "newthread()". You could set it up like this.


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.

webjoker
01-02-2012, 08:43 PM
You would have a function such as "newthread()". You could set it up like this.


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. :)

tangoforce
01-02-2012, 08:48 PM
Easiest thing to do would be to download and install a forum such as phpbb.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum