Psycho-Path Posted December 28, 2006 Share Posted December 28, 2006 Ok I have some forums on my site and I would like to customize for it to be most like the leading ones out there (ipb, phpbb, vb, etc.)So I have the basics setup right now, but I would like to make it so there is:registration for membership pagemember pagelogin pagebbcode on postingetc etcI'm not asking for people to just change my script for me, cause I'm not a freeloader, I like doing work. But I like getting help as well :)So here are the files I have so far.forums.php[code]<?phpinclude "connect.php"; //mysql db connection hereprint "<link rel='stylesheet' href='style.css' type='text/css'>";print "<table class='maintable'>";print "<tr class='headline'><td width=40% class='headline-text'>Topic</td><td width=20% class='headline-text'>Topic Starter</td><td width=15% class='headline-text'>Replies</td><td class='headline-text'>Last replied time</td></tr>";$getthreads="SELECT * from forumtutorial_posts where parentid='0' order by lastrepliedto DESC";$getthreads2=mysql_query($getthreads) or die("Could not get threads");while($getthreads3=mysql_fetch_array($getthreads2)){$getthreads3[title]=strip_tags($getthreads3[title]);$getthreads3[author]=strip_tags($getthreads3[author]);print "<tr class='mainrow'><td><a class='topic' href='index.php?act=topics&id=$getthreads3[postid]'>$getthreads3[title]</a></td><td class='info-text'>$getthreads3[author]</td><td class='info-text'>$getthreads3[numreplies]</td><td class='info-text'>$getthreads3[showtime]<br> Last post by <b>$getthreads3[lastposter]</b></td></tr>";}print "</table>";?> [/code]post.php[code]<?phpinclude "connect.php"; //connection stringprint "<link rel='stylesheet' href='style.css' type='text/css'>";print "<table class='maintables'>";print "<tr class='headline'><td>Post a message</td></tr>";print "<tr class='maintables'><td>";if(isset($_POST['submit'])){$name=$_POST['name'];$yourpost=$_POST['yourpost'];$subject=$_POST['subject'];if(strlen($name)<1){print "You did not type in a name."; //no name entered}else if(strlen($yourpost)<1){print "You did not type in a post."; //no post entered}else if(strlen($subject)<1){print "You did not enter a subject."; //no subject entered}else{$thedate=date("U"); //get unix timestamp$displaytime=date("F j, Y, g:i a");//we now strip HTML injections$subject=strip_tags($subject);$name=strip_tags($name);$yourpost=strip_tags($yourpost);$insertpost="INSERT INTO forumtutorial_posts(author,title,post,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$displaytime','$thedate','$name')";mysql_query($insertpost) or die("Could not insert post"); //insert postprint "Message posted, go back to <A href='index.php'>Forum</a>.";}}else{print "<form action='post.php' method='post'>";print "Your name:<br>";print "<input type='text' name='name' size='20'><br>";print "Subject:<br>";print "<input type='text' name='subject' size='20'><br>";print "Your message:<br>";print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";print "<input type='submit' name='submit' value='submit'></form>";}print "</td></tr></table>";?>[/code]reply.php[code]<?phpinclude "connect.php"; //connection stringprint "<link rel='stylesheet' href='style.css' type='text/css'>";print "<table class='maintables'>";print "<tr class='headline'><td>Reply</td></tr>";print "<tr class='maintables'><td>";if(isset($_POST['submit'])){$name=$_POST['name'];$yourpost=$_POST['yourpost'];$subject=$_POST['subject'];$id=$_POST['id'];if(strlen($name)<1){print "You did not type in a name."; //no name entered}else if(strlen($yourpost)<1){print "You did not type in a post."; //no post entered}else{$thedate=date("U"); //get unix timestamp$displaytime=date("F j, Y, g:i a");//we now strip HTML injections$subject=strip_tags($subject);$name=strip_tags($name);$yourpost=strip_tags($yourpost);$insertpost="INSERT INTO forumtutorial_posts(author,title,post,showtime,realtime,lastposter,parentid) values('$name','$subject','$yourpost','$displaytime','$thedate','$name','$id')";mysql_query($insertpost) or die("Could not insert post"); //insert post$updatepost="Update forumtutorial_posts set numreplies=numreplies+'1', lastposter='$name',showtime='$displaytime', lastrepliedto='$thedate' where postid='$id'";mysql_query($updatepost) or die("Could not update post");print "Message posted, go back to <A href='message.php?id=$id'>Message</a>.";}}else{$id=$_GET['id'];print "<form action='reply.php' method='post'>";print "<input type='hidden' name='id' value='$id'>";print "Your name:<br>";print "<input type='text' name='name' size='20'><br>";print "Your message:<br>";print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>";print "<input type='submit' name='submit' value='submit'></form>";}print "</td></tr></table>";?>[/code]topics.php[code]<?phpinclude "connect.php"; //mysql db connection here$id=$_GET['id'];print "<link rel='stylesheet' href='style.css' type='text/css'>";$getthreads="SELECT * from forumtutorial_posts where parentid='0' order by lastrepliedto DESC";$getthreads2=mysql_query($getthreads) or die("Could not get threads");{$getthreads3[title]=strip_tags($getthreads3[title]);$getthreads3[author]=strip_tags($getthreads3[author]);print "<font class='title-top'>Forums -> Topic</font>";print "<br />";}print "<table class='maintable'>";print "<tr class='headline'><td width=20%>Author</td><td width=80%>Post</td></tr>";$gettopic="SELECT * from forumtutorial_posts where postid='$id'";$gettopic2=mysql_query($gettopic) or die("Could not get topic");$gettopic3=mysql_fetch_array($gettopic2);print "<tr class='mainrow'><td valign='top'>$gettopic3[author]</td><td valign='top'>This topic was made on $gettopic3[showtime]<br><hr>";$message=strip_tags($gettopic3['post']);$message=nl2br($message);print "$message<br /><br />";print "</td></tr>";$getreplies="SELECT * from forumtutorial_posts where parentid='$id' order by postid desc"; //getting replies$getreplies2=mysql_query($getreplies) or die("Could not get replies");while($getreplies3=mysql_fetch_array($getreplies2)){print "<tr class='mainrow'><td valign='top'>$getreplies3[author]</td><td valign='top'>Last replied to at $getreplies3[showtime]<br><hr>";$message=strip_tags($getreplies3['post']);$message=nl2br($message);print "$message<br /><br />";print "</td></tr>";print "<tr class='mainrow'><td valign='top'><a class='topic' href='index.php?act=post&id=$getthreads3[postid]'>Reply<br>";print "</td></tr>";}print "</table>";?>[/code]ok those are all the files I have, could you guys direct me in some tutorials that could give me help or if you could help me on the things I asked for.Thanks A BUNCH!Andrew Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 28, 2006 Share Posted December 28, 2006 http://www.tutorialized.com/tutorial/Discussion-Forums-with-PHP/609 Quote Link to comment Share on other sites More sharing options...
Psycho-Path Posted December 29, 2006 Author Share Posted December 29, 2006 Please people, I need more tuts, ideas, and help. Quote Link to comment Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 Your question is not AT ALL specific enough. Start with one question at a time. What is it you need help with? If your just looking for tutorials try google. Quote Link to comment Share on other sites More sharing options...
Psycho-Path Posted December 29, 2006 Author Share Posted December 29, 2006 Sorry I thought I was clear.And it's not quite a question but a request.A request to have tutorials, help, etc, on adding these to my forums:registration to be a membermember profile pagelogin pagebbcode on postingpmingcatagoriesetc etc. Quote Link to comment Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 Well, Im sorry, but that is much to vague and broad a request. Have you got a login system in place? Maybe a search for 'php user login tutorials' would be a goood place to start. Quote Link to comment Share on other sites More sharing options...
Psycho-Path Posted December 29, 2006 Author Share Posted December 29, 2006 Alright, then can you just help me with the catagories? I can't find anything on them muchless forum tutorials that have catagories. Quote Link to comment Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 You would simply need to create a database table called catigories. This would hold an id and the name of the catigory. Then, in the table that holds the threads make another field called cat_id, this would hold the catigory id for each thread.To list all threads in catigory 5 for instance you would use a simple query something like...[code]SELECT topic FROM threads WHERE cat_id = 5;[/code] Quote Link to comment Share on other sites More sharing options...
Psycho-Path Posted December 29, 2006 Author Share Posted December 29, 2006 For the creation of a new table called catagories would this be ok sql?[code]CREATE TABLE `forum_cat` (`id` INT(11) NOT NULL AUTO_INCREMENT,`name` VARCHAR(250) NOT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM;[/code]and then for the table that holds the threads[code]SELECT * FROM `forum_posts` WHERE 1`cat_id` VARCHAR(250) NOT NULL,) ENGINE=MyISAM;[/code]is that correct? Quote Link to comment Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 forum_cat is correct, Im not sure what your doing in the other part though. You need to add the field cat_id to whatever table it is your storing your threads in. So it would be more like....[code]ALTER TABLE forum_posts ADD cat_id INT(11);[/code] Quote Link to comment Share on other sites More sharing options...
Psycho-Path Posted December 29, 2006 Author Share Posted December 29, 2006 I think I have made enough threads so I'm just going to post it in here...I have this register page for users, and the page is blank, I think it's the if statements that are screwing up.[code="register.php"]<?phprequire ("connect.php"); //mysql db connection hererequire ("functions.php");//echo some styles to spice it up...echo "<style>body { background: 131313; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: FFFFFF;}.register_box { border: 1px solid 323232; background: 202020; font-family: Verdana, Arial; font-weight: bold; font-size: 9px; color: FFFFFF;}</style>";echo "<font class='title-top'>Register</font><br />";switch($_GET['action']){ case "new"://--------------------------------------// [New Registration]//-------------------------------------- if(!isset($_POST['register'])) { echo " <form action='index.php?act=register.php&action=new' method='POST'> Username: <br /> <input type='text' name='username' class='register_box'> <br /> Email: <br /> <input type='text' name='email' class='register_box'> <br /> Password: <br /> <input type='password' name='password' class='register_box'> <br /> <input type='submit' name='register' value='Register' class='register_box'> </form> "; } elseif(isset($_POST['register'])) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $email = mysql_real_escape_string($_POST['email']); $activation_code = generateCode(25); $userq = "SELECT username FROM user_system WHERE username = '$username' LIMIT 1"; $emailq = "SELECT email FROM user_system WHERE email = '$email' LIMIT 1"; //put errors into an array $errors = array(); if(empty($username)) { $errors[] = "The username field was blank! <br />"; } if(mysql_num_rows(mysql_query($userq)) > 0) { $errors[] = "The username given is already in use! Please try another one! <br />"; } if(empty($password)) { $errors[] = "The password field was blank! <br />"; } if(empty($email)) { $errors[] = "The email field was blank! <br />"; } if(mysql_num_rows(mysql_query($emailq)) > 0) { $errors[] = "The email given is already in use! Please try another one! <br />"; } if(count($errors) > 0) { foreach($errors as $err) { echo $err; } } else { $sqlq = "INSERT INTO user_system (username, password, email, is_activated, activation_code)"; $sqlq .= "VALUES ('$username', '".md5($password)."', '$email', '0', '$activation_code')"; mysql_query($sqlq) or die(mysql_error()); echo "Thanks for registering! You will recieve an email shortly containing your validation code, and a link to activate your account!"; mail($email, "New Registration, localhost", " Thanks for registering at the site. Here are your login details: Username: ".$username." Password: ".$password." In order to login and gain full access, you must validate your account. Click here to validate: http://localhost/test/index.php?act=register.php&action=activate&user=".$username."&code=".$activation_code." Thanks! [Webmaster] "); } } break;}?> [/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.