I have been looking to see if there are any answers for this already, and i haven't found one that answers my question. I am a noob when it comes to php, so please be nice. I am trying to make a somewhat of a CMS and all i have so far is you can make post, but when ever i try to store the time of the post, it just outputs December 31 1969. I am assuming i am not storing the value properly because if its showing that date, it means the timer is at 0.
Here is what i have so far.
<?php
require('config.php');
if (isset($_POST['name']) AND isset($_POST['mail']) AND isset($_POST['avatar']) AND isset($_POST['title']) AND isset($_POST['message']))
{
$name = addslashes($_POST['name']);
$mail = addslashes($_POST['mail']);
$avatar = addslashes($_POST['avatar']);
$title = addslashes($_POST['title']);
$message = addslashes($_POST['message']);
// We try to find out if we were going to modify the news ...
if ($_POST['id_news'] == 0)
{
// No modifs ?? lets put some data on the tables :p
mysql_query("INSERT INTO news VALUES('', '" . $name . "', '" . $title . "', '" . $message . "', '" . time() . "', '" . $mail . "', '" . $avatar . "')");
}
else
{
// If we want to modify, let's just update all the data
mysql_query("UPDATE news SET name='" . $name . "', title='" . $title . "', message='" . $message . "', mail='" . $mail . "', avatar='" . $avatar . "' WHERE id=" . $_POST['id_news']);
}
}
/*
Verify if ever we want to delete the news
*/
if (isset($_GET['delete_news']))
{
// let's delete data Very Happy
mysql_query('DELETE FROM news WHERE id=' . $_GET['delete_news']);
}
?>
<table width="487">
<tr>
<th>Modify</th>
<th>Delete</th>
<th>Title</th>
<th>Date</th>
<th>Author</th>
</tr>
<?php
$res = mysql_query('SELECT * FROM news ORDER BY id DESC');
while ($data = mysql_fetch_array($res))
{
?>
<tr>
<td align="center"><?php echo '<a href="write_news.php?modify_news=' . $data['id'] . '">'; ?>Modify</a></td>
<td align="center"><?php echo '<a href="list_news.php?delete_news=' . $data['id'] . '">'; ?>Delete</a></td>
<td align="center"><?php echo stripslashes($data['title']); ?></td>
<td align="center"><?php echo date('d F Y - h:i:s a', $data['time']); ?></td>
<td align="center"><?php echo stripslashes($data['name']); ?></td>
</tr>
<?php
}
?>
Thank you in advance.