For some reason or another the date and time in my date column shows 0000-00-00 00:00:00
when I submit my form to my DB. Only way I can get the date right is by updating it manually. It just started doing it and I'm not sure what I changed. I'm having a real hard time troubleshooting this.
Edit form:
<?php
if(!defined('IN_ADMIN')) exit;
?>
<div class="page">
<h1 class="edit"><?=ucfirst($mode)?> post</h1>
<span class="error-text"><?=$response_text?></span>
<form action="admin.php?mode=<?=$mode?>&id=<?=$post['post_id']?>" method="post">
<p>
<label for="title">Post title:</label><br />
<input type="text" size="80" id="title" name="data[post_title]" value="<?=htmlspecialchars(stripslashes($post['post_title']))?>" />
</p>
<p>
<label for="title">Upload Image:</label><br />
<input type="text" size="80" id="title" name="data[image]" value="<?=htmlspecialchars(stripslashes($post['image']))?>" />
</p>
<p>
<label for="title">Image Alt:</label><br />
<input type="text" size="80" id="title" name="data[image_alt]" value="<?=htmlspecialchars(stripslashes($post['image_alt']))?>" />
</p>
<p>
<label for="title">Post Category:</label><br />
<input type="text" size="80" id="title" name="data[post_category]" value="<?=htmlspecialchars(stripslashes($post['post_category']))?>" />
</p>
<p>
<label for="content">Post Insert:</label><br />
<textarea cols="77" rows="10" id="insert" name="data[post_insert]"><?=htmlspecialchars(stripslashes($post['post_insert']))?></textarea><br />
<span class="form-text">Brief little tid-bit about the article for home page</span>
</p>
<p>
<label for="content">Post content:</label><br />
<script>edToolbar('mytxtarea'); </script>
<textarea cols="77" rows="10" id="mytxtarea" class="ed" name="data[post_content]"><?=htmlspecialchars(stripslashes($post['post_content']))?></textarea><br />
<span class="form-text">To format just use raw HTML.. <strong>, <span>, etc</span>
</p>
<p>
<label for="status">Post status:</label><br />
<select id="status" name="data[published]">
<?=generate_option_list(array('0' => 'Unpublished', '1' => 'Published'), $post['published'])?>
</select>
</p>
<p>
<input class="button" type="submit" name="miniblog_PostBack" value="<?=ucfirst($mode)?>" />
</p>
</div>
That's the form that I use, and here is the index.php that the form is in:
case 'add':
if(isset($_POST['miniblog_PostBack']))
{
$data = $_POST['data'];
$data['post_slug'] = mb_slug($_POST['data']['post_title']);
$data['date'] = time();
$sql ='';
$i = 1;
foreach($data as $field => $value)
{
if($value == '')
{
$failed = true;
break;
}
$fields .= "`" . mysql_real_escape_string($field) . "`";
$values .= "'" . mysql_real_escape_string($value) . "'";
$values .= ($i == sizeof($data)) ? '' : ', ';
$fields .= ($i == sizeof($data)) ? '' : ', ';
$i++;
}
$post = $_POST['data'];
if($failed)
{
$response_text = 'Error: You must fill out all fields';
}
else
{
$result = mysql_query("INSERT INTO `db` ({$fields}) VALUES({$values})");
$response_text = ($result) ? 'Post added' : 'Post could not be added';
}
}
include('edit.php');
break;