Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2004
    Posts
    3

    Unanswered: how to make an asp forum

    hi! if i want to make a forum using asp, how to make relation between tables? in access or with dreamweaver coding or else? Can u help me find tutorials to make a forum? thanks a lot

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Your desire to write an ASP forum is curious... given the complexity of such a chore and the obvious newbie questions about how to start.

    Why not just use one of the many totally FREE ASP Forum applications out there. MegaBBS, Snitz, WebWiz... all offer their code for free. Since they've been around for a while, they're also fairly bug free. There are many more out there also.

    So, unless you're just looking to torture yourself....?

    Tim
    Tim

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Relationships are managed at the database level.

    If you have a table of users, and a table of messages, your user table will have an ID number, and the messages table will have a field that relates to the users table.

    tblUsers
    ID - primary key field, Integer, Indentity seed starting at 1, incrementing 1
    LoginID - nvarchar
    Name - nvarchar

    tblForums
    ID - primary key field, Integer, Indentity seed starting at 1, incrementing 1
    Forum - nvarchar
    Description - nvarchar

    tblMessages
    ID - primary key field, Integer, Indentity seed starting at 1, incrementing 1
    ForumID - key field, integer
    UserID - key field, integer
    TimeStamp - smalldatetime

    Now when you want get the messages for a forum, you use an SQL JOIN.

    SELECT * FROM tblMessages m INNER JOIN tblUsers u ON m.UserID = u.UserID INNER JOIN tblForums f ON m.ForumID = f.ForumID WHERE f.ForumID = <forum number>

    You can set up constraints on the tables that ensure that a User and Forum exists for every message in the table. You could even set up a cascading delete that would automatically remove rows from the messages table if the user was removed... but use that with care.. you can create data integrity issues doing so.
    That which does not kill me postpones the inevitable.

  4. #4
    Join Date
    Jul 2004
    Posts
    3
    Mr. wizard, actually i'm really a newbie in asp, i want to know how it works. I know i'll torture myself... hahaha, it's inevitable, right?

    Seppuku, Thanks for the tips on sql. It really helps.

  5. #5
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Half of your work will be DB and SQL design. If you have the option, go with a database server such as Microsoft SQL Server or mySQL. Avoid Microsoft Access if at all possible. Then research Stored Procedures, and develop your forum around them. They provide enhanced security, and increased performance.

    Let SQL handle the logic of what rows to retrieve, then use ASP to simply display that information returned. The fewer number of rows and columns transfered from database server to web server, the better.
    That which does not kill me postpones the inevitable.

  6. #6
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Oh, and you'll need a user registration page that allows you to register new users by adding a new row to the tblUsers table. Make sure you encrypt the password. Look up MD5. There are several scripts out there that will convert a string into a MD5 hash that is unidirectional. If you can't find one, let me know, I have one here somewhere.

    So your new user will provide a loginID, password (and confirmed password) and email address as a minimum amount of information. When submit, first check to make sure the loginID isn't already taken. Use SQL to do this check (don't get all the rows in tblUsers and then use ASP to loop through the recordset, instead, use a WHERE clause in your SQL ...WHERE LoginID LIKE 'bob', don't forget to use stored procedures). If the ID doesn't already exist, do a SQL INSERT (again, through a Stored Procedure) to add the row, but make sure you have a flag that says that they are probationary. Either use CDONTS, ASPMail, or other email component to send an email to the user with a link to an ASP page that changes that flag to an active status.

    Then when you log the user on, check to make sure that the loginID and MD5'ed ENTERED password match a loginID and MD5'ed STORED password in the DB. If so, create a cookie which validates their authentication for the duration of their visit, then redirect them back to the forum. When you're working with cookies, you have to write them before anything else is written to the browser (but cookies can be *read* at any time in the ASP script), and secondly, redirects have to be called before any text is written to the browser. Redirects and new/update cookies are sent as Headers, which cannot be sent after text is written because the rest of the Headers are automatically sent with the first bit of HTML (unless you manually remove them all).

    When I do logins, I have an ASP page that does not write any HTML. It simply takes form inputs, does the validation from the DB, writes an authentication cookie if necessary, and does a redirect.
    That which does not kill me postpones the inevitable.

  7. #7
    Join Date
    Jul 2004
    Posts
    3
    wow... thanks a lot seppuku, your explanation is very clear. but, unfortunately right now i only know microsoft access. but i understand the logic.

    what about the table? do i make 1 table for each topic and 1 table for user?
    (i inted to make a very simple asp which has basic function of forum like add thread, add user, view details, admin add topic, etc.)

  8. #8
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    In a very basic forum, you'd need at least three forums. Check out post #3 in this thread.
    That which does not kill me postpones the inevitable.

Posting Permissions

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