Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Forum board unsolved

Links for php scripts

Moderators: macek, egami, gesf

Forum board unsolved

Postby IamNew » Tue Mar 06, 2012 5:57 pm

I have written codes create a forum board to be added into my website by using php and mysql. I have some problem here, the 'Numbers of Reply', 'Last Replied Time' and 'Last Replied by who' could not being updated when there are replies.

Here's the code (elec_forum.php):
Code: Select all
<p ><h3 align="center">Department of Electronic Engineering</h3>

include "connect.php"; //mysql db connection here

print "<link rel='stylesheet' href='style.css' type='text/css'>";

print "<A href='elec_post.php'>New Topic</a><br>";

print "<table class='maintable'>";

print "<tr class='headline'><td width=50%>Discussion Topic</td><td width=20%>Author</td><td>Replies</td><td>Last replied time</td></tr>";

$getthreads="SELECT * from elec_forum where parentid='0' order by lastrepliedto DESC";

$getthreads2=mysql_query($getthreads) or die("Could not get threads");





  print "<tr class='mainrow'><td><a href='elec_message.php?id=$getthreads3[postid]'>$getthreads3[title]</a></td><td>$getthreads3[author]</td><td>$getthreads3[numreplies]</td><td>$getthreads3[showtime]<br>Last post by <b>$getthreads3[lastposter]</b></td></tr>";


print "</table>";


Here's the reply code (elec_reply.php):
Code: Select all

include "connect.php"; //connection string

print "<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>";









      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



      $thedate=date("U"); //get unix timestamp

      $displaytime=date("F j, Y, g:i a");

      //we now strip HTML injections




      $insertpost="INSERT INTO elec_forum(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

      print "Message updated, go back to <A href='elec_message.php?id=$id'>Message</a>.";






   print "<form action='elec_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>";


I am not sure where's the problem occurred. Please advise and guide.
New php-forum User
New php-forum User
Posts: 28
Joined: Fri Nov 04, 2011 6:29 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.