func SendForumPost(w http.ResponseWriter, r *http.Request) {
	username, err := r.Cookie("username")
	if err == nil {
		sessionID, err := r.Cookie("sessionID")
		if err == nil {
			if sessionID.Value != "" && gostuff.SessionManager[username.Value] == sessionID.Value {
				log := log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile)
				canPost, seconds := canUserPost(username.Value)
				if canPost == false {
					w.Write([]byte("Please wait " + seconds + " seconds before posting again."))
					return
				}
				firstPost := template.HTMLEscapeString(r.FormValue("firstPost"))
				tempThreadId := template.HTMLEscapeString(r.FormValue("threadId"))
				var threadId int64
				threadId = 0
				if tempThreadId != "" {
					threadId, err = strconv.ParseInt(tempThreadId, 10, 64)
					if err != nil {
						log.Println(err)
					}
				}
				forumTitle := template.HTMLEscapeString(r.FormValue("forumname"))
				threadTitle := template.HTMLEscapeString(r.FormValue("title"))
				message := template.HTMLEscapeString(r.FormValue("message"))
				if len(message) > 800 {
					w.Write([]byte(`<img src='img/ajax/not-available.png' /> 
						Length of forum post is greater then 800 characters`))
					return
				}
				totalPosts := template.HTMLEscapeString(r.FormValue("totalPosts"))
				date := time.Now().Format("20060102150405")
				if firstPost == "Yes" {
					var thread Thread
					thread.ForumTitle = forumTitle
					thread.Username = username.Value
					thread.Title = threadTitle
					thread.Views = 0
					thread.Replies = 0
					thread.LastPost = username.Value
					thread.Date = date
					var post Post
					post.OrderID = 0
					post.Body = message
					post.Username = username.Value
					post.Title = threadTitle
					post.Date = date
					thread.Posts = append(thread.Posts, post)
					updated, forumId := updateForumCount(thread.ForumTitle, post.Username)
					if updated {
						thread.ForumID = forumId
						if thread.createThread() {
							w.Write([]byte("createPost"))
						} else {
							w.Write([]byte("<img src='img/ajax/not-available.png' /> Failed to create new thread"))
						}
						return
					} else {
						w.Write([]byte("<img src='img/ajax/not-available.png' /> Failed to update forum count"))
						return
					}
				} else {
					var post Post
					newTotalPosts, err := strconv.Atoi(totalPosts)
					if err != nil {
						log.Println(err)
					}
					post.ThreadID = threadId
					post.OrderID = newTotalPosts
					post.Body = message
					post.Username = username.Value
					post.Title = threadTitle
					post.Date = date
					if post.createPost() {
						updateThreadReplies(post.ThreadID)
						forumId := getForumId(forumTitle)
						updateLastPost(username.Value, threadId, forumId)
						updateForumPostCount(forumId)
						w.Write([]byte("createPost"))
						return
					} else {
						w.Write([]byte("<img src='img/ajax/not-available.png' /> Failed to create post"))
						return
					}
				}
			}
		}
	}
	w.Write([]byte("<img src='img/ajax/not-available.png' /> Invalid credentials"))
}
Creates the first post in a thread, must be logged in to do this
package goforum
import (
	"html/template"
	"log"
	"net/http"
	"os"
	"strconv"
	"time"
	"github.com/jonpchin/gochess/gostuff"
)
type ThreadSection struct {
	Title   string
	Threads []Thread
}
type Thread struct {
	ID         int64   
	ForumID    int     
	ForumTitle string  
	Username   string  
	Title      string  
	Views      int     
	Replies    int     
	LastPost   string  
	Locked     string  
	Date       string  
	Posts      []Post  
}
func GetThreads(forumId string) (threadSection ThreadSection) {
	log := log.New(os.Stdout, "", log.LstdFlags|log.Lshortfile)
	rows, err := db.Query("SELECT * FROM threads WHERE forumId=?", forumId)
	if err != nil {
		log.Println(err)
	}
	defer rows.Close()
	var thread Thread
	for rows.Next() {
		err = rows.Scan(&thread.ID, &thread.ForumID, &thread.Username, &thread.Title,
			&thread.Views, &thread.Replies, &thread.LastPost, &thread.Locked, &thread.Date)
		if err != nil {
			log.Println(err)
		}
		threadSection.Threads = append(threadSection.Threads, thread)
	}
	threadSection.Title = GetForumTitle(forumId)
	return threadSection
}