Originally posted by treds1
will need to see more of the code to deduce prob, has $node variable been declared anyware?
Thank you for your reply! 🙂
The code is:
forum.php
<?php
// This is the DSN we have create for our database
$connect = odbc_connect("TestDSN", "root", "");
?>
<html>
<body>
Discussion Forum using PHP/Access under IIS<br /><br />
<a href="node.php?node=0">Post New Message</a>
<?php
shownode(0); // display all the main threads
// This function is a recursive function which shall display all the br /anches
// and sub br /anches of the threads
function shownode($nodecode)
{
global $connect; // using the global variable for connection
// Get a list of all the sub nodes which specific parentcode
$noderesult = odbc_exec($connect,"select * from tblForum where parent_ID = $nodecode");
echo '<ul type="disc">';
while(odbc_fetch_row($noderesult)) // get all the rows
{
$code = odbc_result($noderesult,"ID_no");
$title = odbc_result($noderesult,"title");
$uname = odbc_result($noderesult,"uname");
$email = odbc_result($noderesult,"email");
echo "<li>";
echo "<a href=\"node.php?node=$code\"> $title </a>";
echo "-- by ($uname) $email<br />";
shownode($code);
}
echo "</ul>";
}
?>
</body>
</html>
node.php
<?php
$connect = odbc_connect("TestDSN", "root", "");
if(isset($submit)) // check if submitted button is clicked
{
// insert the record in the database
$resultupdate=odbc_exec($connect,"insert into tblForum
(parent_ID,title,description,uname,email) VALUES
($node,'$title','$description','$postname','$email')");
header("location:forum.php"); // open forum.php file to display the thread
exit;
}
?>
<div align="center">Post to Discussion Forum using PHP/Access under IIS</div>
<?
if ( $node != 0 )
{
// Displaying the details of the thread
echo "<hr />";
$noderesult = odbc_exec($connect,"select * from tblForum where ID_no = $node");
$noderow=odbc_fetch_row($noderesult);
$title = odbc_result($noderesult,"title");
$description = odbc_result($noderesult,"description");
$uname = odbc_result($noderesult,"uname");
$email = odbc_result($noderesult,"email");
echo "$title by ($uname) $email<br />";
echo "$description <br /><hr />";
}
?>
<!-- Form to enter the message -->
<form method="post">
Name : <input type="text" name="postname"></input><br />
E-Mail : <input type="text" name="email"></input><br />
Title : <input type="text" name="title" value="" size="50"></input><br />
Description : <br /><textarea name="description" rows="10" cols="45"></textarea>
<!-- we need a hidden field to store the node -->
<input type="hidden" name="node" value="<?php echo $node;?>"><br />
<input type="submit" name="submit" value="Post Message">
</form>
I hope you can help me!
This code is the same as on this server.