Web Analytics Made Easy -
StatCounter Comments box - CodingForum

Announcement

Collapse
No announcement yet.

Comments box

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Comments box

    Hey, i was wondering how to go about creating a text-based database so i could add a comments box to my website. My webserver allows php, but doesnt allow mysql, which is quite annoying but im sure this can be done without...

    cheers for any help

    ciggy

  • #2
    It would involve using a flat-file database (text files).
    Very similar to a guest book I would imagine ...
    http://www.google.com/search?hl=en&q...=Google+Search

    Comment


    • #3
      PHP Code:
      <h5>Comments:</h5><table width="95%">
      <?php
      include 'comments.txt';
      ?>
      </span>
      <?php
      if (!empty($_POST['username']) && !empty($_POST['comment'])){
              
      $fh fopen('comments.txt''a');
              
      $url = (preg_match('/@/'$_POST['contact'])) ? 'mailto:' htmlentities($_POST['contact']) : 'http://' htmlentities($_POST['contact']);
              
      $comment '<tr><td><span style="font-weight:bold; font-size: 1.2em;">' htmlentities($_POST['subject']) . '</span> by <a href="' $url '">' htmlentities($_POST['username']) . '</td></tr><tr><td>' htmlentities($_POST['comment']) . '</td></tr>';
              
      fwrite($fh$comment);
              echo 
      '<meta http-equiv="refresh" content="0">';
      }
      ?>
      </table><form method="post" action="comments.php">
      <table width="90%" border="0" cellspacing="0" cellpadding="0">
         <tr>
            <td><div align="right">Username:   </div></td>
             <td><input name="username" type="text" size="30" value=""></td>
         </tr>
          <tr>
            <td><div align="right">Contact:   </div></td>

            <td><input type="text" name="contact" size="30" value=""> <i>(email or url)</i></td>
          </tr>
          <td><div align="right">Subject:   </div></td>
          <td><input type="text" name="subject" size="30" value=""></td>
          </tr>
          <tr>
            <td><div align="right">Comment:   </div></td>

            <td><textarea name="comment" cols="45" rows="5" wrap="VIRTUAL"></textarea></td>
          </tr>
          <tr>
            <td></td>
            <td colspan="2"><input type="reset" value="Reset Fields">     
              <input type="submit" name="submit" value="Add Comment"></td>
          </tr>
        </table>
      </form>
      </body>
      </html>
      Heres one I made a couple of days ago, you will need to create a file called comments.txt and make sure it has the right permissions.

      Comment

      Working...
      X