This is what I have so far. Would you mind taking a look?
post.php
<?php
$e = mysql_error();
mysql_connect ("localhost", "root", "") or die ($e);
mysql_select_db ("newsfeed") or die ($e);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Post News and Events</title>
</head>
<body>
<?php
if (isset ($_POST["post"]) ) {
$title = $_POST['title'];
$body = $_POST['body'];
if ($title&&$body)
{
$date = date("Y-m-d");
$insert = mysql_query("INSERT INTO news VALUES ('','$title','$body','$date')") or die ($e);
die("Your news has been posted.");
}
else
echo "Please fill out the title and body";
}
?>
<div>
<form action="post.php" method="post">
<div>
<label for="name">Title:<br />
</label>
<input type="text" name="title" id="name" value="" tabindex="1" />
</div>
<div>
<label for="textarea">Body:<br />
</label>
<textarea cols="40" rows="8" name="body" id="textarea"></textarea>
</div>
<div>
<input type="submit" name="post" value="Submit" />
</div>
</form>
</div>
<p>
<?php
if (isset ($_POST["post"]) ) {
$venue = $_POST['venue'];
$description = $_POST['description'];
$other = $_POST['other'];
if ($venue&&$description&&$other) {
$insert = mysql_query("INSERT INTO events VALUES ('','$venue','$description','$other')") or die ($e);
die("Your event has been posted.");
}
else
echo "Please fill out the venue, description and other";
}
?>
</p>
<p> </p>
<div>
<form action="post.php" method="post">
<div>
<label for="name">Venue:<br />
</label>
<input type="text" name="venue" id="name" value="" />
</div>
<div>
<label for="textarea">Description:<br />
</label>
<textarea cols="40" rows="8" name="description" id="textarea"></textarea>
</div>
<div>
<label for="textarea">Other:<br />
</label>
<textarea cols="40" rows="8" name="other" id="textarea"></textarea>
</div>
<div>
<input type="submit" name="post" value="Submit" />
</div>
</form>
</div>
</body>
</html>
news.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$e = mysql_error();
mysql_connect ("localhost", "root", "") or die ($e);
mysql_select_db ("newsfeed") or die ($e);
$getnews = mysql_query("SELECT * FROM news ORDER BY id DESC") or die ($e);
while ($row = mysql_fetch_assoc($getnews)) {
$id = $row['id'];
$title = $row['title'];
$body = $row['body'];
$date = $row['date'];
echo "
$title posted on $date<br />
$body
<hr />
";
}
?>
</body>
</html>
events.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$e = mysql_error();
mysql_connect ("localhost", "root", "") or die ($e);
mysql_select_db ("newsfeed") or die ($e);
$getnews = mysql_query("SELECT * FROM events") or die ($e);
while ($row = mysql_fetch_assoc($getnews)) {
$id = $row['id'];
$venue = $row['venue'];
$desciption = $row['description'];
$other = $row['other'];
echo "
$venue<br />
$desciption<br />
$other
<hr />
";
}
?>
</body>
</html>
SQL
-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 20, 2011 at 05:12 AM
-- Server version: 5.5.8
-- PHP Version: 5.3.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `newsfeed`
--
-- --------------------------------------------------------
--
-- Table structure for table `events`
--
CREATE TABLE IF NOT EXISTS `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`venue` varchar(100) NOT NULL,
`description` text NOT NULL,
`other` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
--
-- Dumping data for table `events`
--
INSERT INTO `events` (`id`, `venue`, `description`, `other`) VALUES
(1, 'dallas', '<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>', 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'),
(2, 'san diego', '<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>', 'Aenean ultricies mi vitae est. Mauris placerat eleifend leo.'),
(3, 'tweet', 'tweeter', 'tweetiest'),
(4, 'tweet', 'tweeter', 'tweetiest'),
(5, 'tweet', 'tweeter', 'tweetiest');
-- --------------------------------------------------------
--
-- Table structure for table `news`
--
CREATE TABLE IF NOT EXISTS `news` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`body` text NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `news`
--
INSERT INTO `news` (`id`, `title`, `body`, `date`) VALUES
(1, 'blah', 'blah', '2011-10-18'),
(2, 'doink', 'doink', '2011-10-19'),
(3, 'test', 'test', '2011-10-20');