The table and database are both named database1.
Here is what I'm working with:
Form:
<form method="post" action="insert.php">
Date: (YYYY-MM-DD)<br/>
<input type="text" name="dateum" size="30"><br/>
Time: <br/>
<input type="text" name="time" size="30"><br/>
Venue: <br/>
<input type="text" name="venue" size="30"><br/>
Location: <br/>
<input type="text" name="location" size="30"><br/>
Event Information: <br/>
<textarea name="event" rows="5" cols="30"></textarea><br/>
<input type="Submit"/>
</form><br/><br/>
<a href="clearevents.php">Clear past events</a>
Insert:
<?php
$date = $_POST['date'];
$time = $_POST['time'];
$venue = $_POST['venue'];
$location = $_POST['location'];
$event = $_POST['event'];
define('DB_NAME', 'database1');
define('DB_USER', 'xxx');
define('DB_PASSWORD', 'xxx');
define('DB_HOST', 'xxx');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die ('No' . DB_NAME . ':' . mysql_error());
}
$value = $_POST['name'];
$sql = "INSERT INTO database1 (ID, dateum, time, venue, location, event) VALUES ('NULL', '$dateum', '$time', '$venue', '$location', '$event')";
if (!mysql_query($sql)) {
die('Error ' . mysql_error());
}
echo "Event added";
?>
<?php
mysql_connect ("xxx", "xxx", "xxx") or die ('I cannont connect: ' . mysql_error());
mysql_select_db ("database1");
$sql = "SELECT ID, time, dateum, venue, location, event FROM database1 ORDER BY dateum DESC";
$result = mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_assoc($result)) {
$dateum=$row["dateum"];
$time=$row["time"];
$venue=$row["venue"];
$location=$row["location"];
$event=$row["event"];
echo "<b>";
echo $dateum;
echo "</b><br/>";
echo $time;
echo "<br/>";
echo $venue;
echo "<br/>";
echo $location;
echo "<br/><br/>";
echo $event;
echo "<br/><br/><hr/><br/>";}
?>
This is the result:
0000-00-00
4:00 PM
This place
This location
This is an event
0000-00-00 should be 2012-04-16 (that's what I typed into the form)
Everything is showing except the date now, I can't figure out what I'm doing wrong with the dates.
Maybe setting it up wrong on phpmyadmin? Does this look OK or should I change something?
Field: dateum
Type: date
Collation: (blank)
Attributes: (blank)
Null: No
Default: (blank)
Extra: (blank)
Thanks again for the help. I'm obviously very new to this.