<?php
$connect = odbc_connect("forum", "root", "");
if(isset($submit)) // check if submitted button is clicked
{
// insert the record in the database
$resultupdate=odbc_exec($connect,"insert into forum
(parentcode,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 forum where code = $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>
Installing PHP under IIS and creating a Discussion Page 7
This is the code for the second PHP file (node.php) file.