| 
<?php
 include("settings.php");
 
 function display_form($yer_or_no) {
 ?>
 <?php
 switch ($yer_or_no)
 {
 case "yes":
 ?>
 
 <?php
 if ($_SESSION['email'] == "on"):
 ?>
 *type a valid email<br />
 <?php
 unset($_SESSION['email']);
 endif;
 if ($_SESSION['lenght'] == "on"):
 ?>
 *respect the maxim lenght<br />
 <?php endif;
 unset($_SESSION['lenght']);
 if ($_SESSION['spam'] == "on"):
 ?>
 *You can't type urls in the history<br />
 <?php
 unset($_SESSION['spam']);
 endif;
 if ($_SESSION['fields'] == "on"):
 ?>
 *you must fill all the fields<br />
 <?php
 unset($_SESSION['fields']);
 endif;
 if($_SESSION['published'] == "yes"):
 unset($_SESSION['the_history']);
 ?>
 published!
 <?php
 unset($_SESSION['published']);
 endif;
 ?>
 <form name="post_comment" method="post" action="data_file.php">
 name<br />
 <input type="text" name="name" id="name" value="<?php echo $_SESSION['the_name']; ?>">
 <br>
 email
 <br />
 <input type="text" name="email" id="email" value="<?php echo $_SESSION['the_email']; ?>">
 <br />
 history<br>
 <textarea name="history" id="history" cols="45" rows="5"><?php echo $_SESSION['the_history']; unset($_SESSION['the_history']); ?></textarea>
 <input name="return" type="hidden" id="return" value="<?php echo $_SERVER['REQUEST_URI']; ?>">
 <br />
 <input type="submit" name="send" id="send" value="Submit">
 </form>
 <?php
 break;
 case "no":
 echo "<small>Unables comments for this page</small>";
 break;
 default:
 echo "<small>unknown parameter</small>";
 }
 ?>
 <?php
 }
 function display_comments($limit) {        //type 0 if you want to show all the comments
 ?>
 <?php
 if ($limit != 0)
 {
 $query_list = mysql_query("SELECT * FROM comments WHERE location='$_SERVER[REQUEST_URI]' ORDER BY id DESC LIMIT $limit");
 }
 else
 {
 $query_list = mysql_query("SELECT * FROM comments WHERE location='$_SERVER[REQUEST_URI]' ORDER BY id DESC ");
 }
 if (mysql_num_rows($query_list) == 0)
 {
 echo "<i>no comments to display</i>";
 } else {
 while($info_list = mysql_fetch_array($query_list)):
 ?>
 <strong><?php echo $info_list[name]; ?></strong>, <?php echo $info_list[date]; ?>
 <ul>
 <li><?php echo str_replace("\n", "<br />", $info_list[history]); ?></li>
 </ul>
 <?php
 endwhile;
 }
 }
 ?>
 |