I am trying to create a small type of a forum for user interaction on a web site I am working on for a local church.
When posting a new topic, the four variables are stored in index.js and the total amount of topics is stored in index.log
the only contents of index.log is the total number of topics
index.js
Code: Select all
var date1='date'
var title1='title'
var name1='name'
var prayer1='prayer'
post.php
Code: Select all
<?php
//retrieves the total topics from index.log as $result
$result++;
$writeTopic = fopen ( "index.js", "a" );
fwrite ( $writeTopic, "var date".$result."='".date ( "m/d/Y" )."'" );
fwrite ( $writeTopic, "\nvar name".$result."='".$_POST["name"]."'" );
fwrite ( $writeTopic, "\nvar title".$result."='".$_POST["title"]."'" );
fwrite ( $writeTopic, "\nvar prayer".$result."='".$_POST["prayer"]."'\n\n" );
fclose ( $writeTopic );
//rewrites $result in index.log
?>
home.php?page=1
irrelevant code is missing
Code: Select all
<script src="index.js">
</script>
<?php
//code that retrieves the number from index.log to $result
$call = $result;
$pageTest = 30 * $_GET["page"];
$nextPage = 0;
if ( $_GET['page'] != 1 )
{
$st = $_GET['page'] - 1;
$st = 30 * $st;
$st = $call - $st;
$call = $st;
}
else
{
$num = $call;
}
if ( $pageTest < $call )
{
$nextPage = 1;
$num = 30;
}
else
{
$num = $st;
}
while ( $num > 0 )
{
echo "<tr bgcolor='#DFE6EF'><td><script language='JavaScript' type='text/javascript'>document.write(date".$call.");</script></td>";
echo "<td><a href='topic.php?view=".$call."&page=".$_GET['page']."' class='link'><script language='JavaScript' type='text/javascript'>document.write(title".$call.");</script></a></td>";
echo "<td><script language='JavaScript' type='text/javascript'>document.write(name".$call.");</script></td></tr>";
$num--;
$call--;
}
echo "</table><br><br>";
$dPage = $_GET['page'] + 1;
if ( $nextPage == 1 )
{
echo "<a href='home.php?page=".$dPage."' class='link'>next page</a>";
}
else
{
echo "next page";
}
?>
and next page turned into a link. When I clicked the link page=2 was displayed and the last two topics were displayed.
Then I posted another topic, when I did so, none of the topics will display. I've restarted and still they won't display.
Any help or ideas would be greatly appreciated.
Thanks,
Travis