config.php

<?php
// This is the configration file, below you can set the settings.
// There is also some help, so if you are a noob, you still can
// use this script. Some are filled in by defaults.
  
  // Your mysql settings, I think you should know this
  $host = 'localhost';
  $user = 'root';
  $pass = '';
  $db   = 'news_sys';
  
  // Now the url you want to store your txt file's in
  $file_url = 'news/';
  $file_ext = '.txt';

// This was it 
// If you don't want to edit the scripts, you can use it for now on
// 
// Thomas Van der Ploeg  
?>


add_news.php

<?php
  include('config.php');
  
  mysql_connect($host, $user, $pass);
  mysql_select_db($db);
  
  if($_POST['submit'] && $_POST['title'] && $_POST['writer'] && $_POST['text']){
    $sql = "SELECT * FROM news";
	$result = mysql_query($sql);
	$num = mysql_num_rows($result);
	
	if($num == 0){
	  $id = 0;
	}else{
	  $id = $num;
	}

	$title = $_POST['title'];
	$writer = $_POST['writer'];
	$text = $_POST['text'];
	echo $text."<br>";
	$date = date("d-m-Y H:i");
	
	$fn = $id.$file_ext;
	$fp = fopen($file_url.$fn, 'a');
	fputs($fp, $text);
	fclose($fp);

    $sql = "INSERT INTO news (id, title, writer, posted_at, text_url) VALUES ('".$id."', '".$title."', '".$writer."', '".$date."', '".$file_url.$fn."')";
	mysql_query($sql);
	mysql_close();
	
	echo '<meta http-equiv="Refresh" content="0;url=add_news.php">';
  }else{
?>
<form method="post" action="<?php echo $PHP_SELF ?>">
<table width="700" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" width="100">Title</td>
    <td><input type="text" name="title"></td>
  </tr>
  <tr>
    <td valign="top" width="100">Writer</td>
    <td><input type="text" name="writer"></td>
  </tr>
  <tr>
    <td valign="top" width="100">Your news</td>
    <td><textarea cols="75" rows="15" name="text"></textarea></td>
  </tr>
  <tr>
    <td colspan="2"><input name="submit" type="submit" value="Add news"></td>
  </tr>
</table>
</form>
<?php 
  }
?>


news.php

<?php
// This page can you edit like u want. Important is to keep te config file 
// included. You can edit the while loop. That's the most important thing
// for the face of the script 

  include('config.php');
  
  mysql_connect($host, $user, $pass);
  mysql_select_db($db);
  
  $sql = "SELECT * FROM news";
  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
  
  while($row = mysql_fetch_array($result)){
    echo "<font size=4><b>".$row['title']."</b></font><br><font size=1>".$row['writer']."</font>";
	echo "<font size=-2> - ".$row['posted_at']."</font><br><br>";
	echo "<font size=-1>";
	include($row['text_url']);
	echo "</font>";
  }
  
  mysql_close();
// All rights reserved
// Thomas Van der Ploeg  
?>
