I have written the code for a discussion forum using the "Installing PHP under IIS and creating a Discussion Forum with Access Database" tutorial. I'm trying to make it a bit more advanced if thats the right word but I've come into some difficulties.
When you reply to a post (using node.php) you have a form you fill in there is a hidden input field
<input type="hidden" name="node" value="<?php echo $node;?>">
. The problem I'm having is that when you submit the form it sends it to post.php but all it sends is the string $node not the numerical value you of it.
I know this because I commented out most of my post.php and added a print function and you can see that this is all it does.
Could this also be the reason why it does not show the details of the post (I'll put the full could at the end)
if ( $node != 0 )
{...}
because $node is not an integer its a string (for some reason)
Sorry if this is a bit long winded but I've been stuck for hours and its getting very frustrating.
cheers,
Tom
node.php
<?php
session_start();
?>
<div align="center"><img src="images\logo.gif"></div>
<?php
if ( $node != 0 )
{
// Displaying the details of the thread
echo "<hr />";
$noderesult = odbc_exec($connect,"select * from forum where code = $node");
$noderow = odbc_fetch_row($noderesult);
$title = odbc_result($noderesult,"title");
$description = odbc_result($noderesult,"description");
$uname = odbc_result($noderesult,"uname");
echo "$title by $uname<br />";
echo "$description <br /><hr />";
}
?>
<!-- Form to enter the message -->
<center>
<form method="post" action="post.php">
<input type="text" name="title" value="" size="50"></input>
<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;?>">
<input type="submit" name="submit" value="Post Message">
<input type="reset" name="reset" value="Clear Fields">
</form>
</center>
post.php
<?php
session_start();
$nodevalue = $_POST['node'];
$title = $_POST['title'];
$description = $_POST['description'];
$postname = ($_SESSION['username']);
$connect = odbc_connect("forum", "root", "");
print $nodevalue;
/*
if (empty($_SESSION['username']))
{
echo '<div align="center"><img src="images\logo.gif"></div>';
echo 'You are not logged in please login.';
echo '<form action="login.html">
<input type="submit" value="LOGIN">
</form>';
}
else
{
// insert the record in the database
//$resultupdate = odbc_exec($connect,"insert into forum (parentcode,title,description,uname) VALUES ($nodevalue ,'$title','$description','$postname')");
echo '$title';
//header("Location: forum.php"); // open forum.php file to display the thread
exit;
} */
?>