I made a Forum - Now I need help.

This is a discussion on "I made a Forum - Now I need help." within the PHP Forum section. This forum, and the thread "I made a Forum - Now I need help. are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 10th, 2007, 17:39
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
I made a Forum - Now I need help.

Hey guys,

Followed a simple tutorial and made a working, functioning very basic PHP forum with a mysql database Yay! I wish I had learnt PHP years ago - it's awesome

Anyway, the forums are here: forums.csstrickery.co.uk and as you can see you have to enter your name every time you post. However, I want the user to login, be redirected to the main forums page (which will be called main_forums.php - it's the index page atm) and then where it says 'Name' I want their username to be displayed. Is that gonna get complicated? I have a login script, which looks like this: (Also - is this login secure?)

PHP: Select all

<?php
$host
="localhost"// Host name 
$username="freesi_admin"// Mysql username 
$password="<my password>"// Mysql password 
$db_name="freesi_phpdatabase"// Database name 
$tbl_name="members"// Table name 

// Connect to server and select databse.
mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo 
"Wrong Username or Password";
}
?>
That all works. I presume that I need to use the session function as it registers the usernames in a session.

So where it says Name, it needs to say the username of the person. I also need the forums to be accessable when not logged in but not allow people to post if they are not logged in. I think I can do this myself - I shall report back! Also, how would I make a 'Users Online' box? And how would I make a 'Last 5 posts' box? Lol I'll be less demanding next time, I promise

Thanks a million for all the help so far with my PHP, I bet you are all fed up of me already

Jack
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 10th, 2007, 17:44
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I made a Forum - Now I need help.

You created your own forum!?! Are you insane!?

Are there free forums out there that I can use for my site? from the FAQ of September's edition of the newsletter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 10th, 2007, 17:48
Highly Reputable Member
Join Date: Jun 2007
Location: Canterbury
Age: 20
Posts: 726
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I made a Forum - Now I need help.

Quote:
Also, how would I make a 'Users Online' box? And how would I make a 'Last 5 posts' box?
For these I think...

Users Online, you'd need a checkbox or boolean field in the users table and you could do a query where it prints the names of all users whose boolean is set to online (1) AND not those who are offline (0) if that makes sense.

Last 5 posts,

Just query the place where the posts go to and grab the last 5 assuming you record the dates the posts were made you can do it like that.

Query posts, order by date descending and limit of 5, it will grab the 5 newest posts!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 10th, 2007, 17:49
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: I made a Forum - Now I need help.

You would be spending months on this if you choose to complete it.
And the end result would be something which doesn't even compare to the free forums available.
I seriously recommend you follow the link Karinne posted and use one right now
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 10th, 2007, 17:50
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I made a Forum - Now I need help.

Even tho I posted that your were insane for making your own, my hats off to you for making it this far
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 10th, 2007, 17:54
welshstew's Avatar
Site Admin

SuperMember
Join Date: May 2007
Location: inside the outside
Posts: 1,713
Blog Entries: 14
Thanks: 4
Thanked 33 Times in 31 Posts
Re: I made a Forum - Now I need help.

try this article, it may help
__________________
WelshStew Site Admin
If you think I've helped, click the "Thanks"
tierney rides tboard - uk site | xtreme wales - extreme clothing
WebForumz - facebook | LinkedIn
Last Blog Entry: Phorm approved for UK rollout (Sep 17th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 10th, 2007, 17:56
Highly Reputable Member
Join Date: Jun 2007
Location: Canterbury
Age: 20
Posts: 726
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I made a Forum - Now I need help.

and yea, KariNNe (woohoo NN!) and Alex are right - although building your own forum is great for learning your never going to get something as good as the free ones that are available...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 10th, 2007, 17:58
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: I made a Forum - Now I need help.

Quote:
Originally Posted by 1840dsgn View Post
great for learning
That's why I decided on a blog instead, half as much work!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 10th, 2007, 18:00
Highly Reputable Member
Join Date: Jun 2007
Location: Canterbury
Age: 20
Posts: 726
Thanks: 0
Thanked 0 Times in 0 Posts
Re: I made a Forum - Now I need help.

yea I did a blog and a CMS for learning. abandoned them cos they were crap but good for learning and then made my CMS which is now...pretty good if i do say so myself
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Oct 10th, 2007, 18:04
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: I made a Forum - Now I need help.

Yeah I want to continue with this one! I now have a registration thing which adds to the database, a login, a forum which you need to be logged in to see and it's going well!

Jack
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Oct 10th, 2007, 18:20
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: I made a Forum - Now I need help.

Hey,

I know it wont be anywhere near as good or anything but it is so I can learn. Can anyone help with my main forums page. It is not even showing now!

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$host="localhost"; // Host name 
$username="freesi_admin"; // Mysql username 
$password="mutley"; // Mysql password 
$db_name="freesi_phpdatabase"; // Database name 
$tbl_name="forum_question"; // Table name  
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending 
$result=mysql_query($sql);
?>
<table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="6%" align="center" bgcolor="#E6E6E6"><strong>#</strong></td>
<td width="53%" align="center" bgcolor="#E6E6E6"><strong>Topic</strong></td>
<td width="15%" align="center" bgcolor="#E6E6E6"><strong>Views</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Replies</strong></td>
<td width="13%" align="center" bgcolor="#E6E6E6"><strong>Date/Time</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){ // Start looping table row 
?>
<tr>
<td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td>
<td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['view']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['reply']; ?></td>
<td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td>
</tr>
<?php
// Exit looping and close connection 
}
mysql_close();
?>
<tr>
<td colspan="5" align="right" bgcolor="#E6E6E6"><p><a href="create_topic.php"><strong>Create New Topic</strong></a><br />
  <a href="logout.php"><strong>Logout</strong> </a></p>
  </td>
</tr>
</table>
</body>
</html>
The error:

Parse error: syntax error, unexpected $end in /home/freesi/public_html/forums/main_forum.php on line 61

Edit: It only has the error when the user is not logged in.
Edit: It now seems to be working!

I think I might try making a PHP blog...


Jack
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)

Last edited by Jack Franklin; Oct 10th, 2007 at 18:22.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Oct 10th, 2007, 18:22
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: I made a Forum - Now I need help.

Quote:
Originally Posted by jackfranklin View Post
The error:

Parse error: syntax error, unexpected $end in /home/freesi/public_html/forums/main_forum.php on line 61

Edit: It only has the error when the user is not logged in.


Jack
Usually an unclosed "{" or "?>".
Count how many "{" are in your in code and check if it's the same as the amount of "}".
Aswell as checking your php tag is closed.
If this doesn't work, port the code from lines 56 - 65.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Oct 10th, 2007, 18:37
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,405
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 Posts
Re: I made a Forum - Now I need help.

There is no code on line 61! The </html> tag is on 59 at that is it lol.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 10th, 2007, 18:46
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: I made a Forum - Now I need help.

Did you do what I recommended? Check if you PHP tags are closed and the curly braces are all closed?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Paid Forum Posting - Political Forum entropy Job Opportunities 0 Sep 22nd, 2007 03:13
PLEASE HELP ME! Swish made flash is blocking fireworks made navbar Sope Flash & Multimedia Forum 12 Jun 19th, 2007 12:29
Director made exe snow Flash & Multimedia Forum 7 Dec 13th, 2006 20:09
HotSeoTalk.com - SEO Forum Search Engine Optimization Ranking Marketing forum hotseotalk Link Building and Link Sales 1 Aug 19th, 2006 09:43


All times are GMT. The time now is 14:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8