achilles1971 Posted March 13, 2013 Share Posted March 13, 2013 <?php ## Blog Manager?> <?phpif (isset($_POST['submitted']) == 1) {if ($_GET['id'] == '') {if ($_POST['title'] =='' || $_POST['body'] == '') {header('Location: index.php?page=blog');} else {$title = $_POST['title'];$date = $_POST['date'];$body = $_POST['body'];$q = "INSERT INTO blog (title, date, body) VALUES ('$title', '$date', '$body')";}}else {$q = "UPDATE blog SET title = '$_POST[title]', date = '$_POST[date]', body = '$_POST[body]' WHERE id = '$_POST[id]'";}$r = mysqli_query($dbc, $q);}?>< h2>ATOM.CMS Blog Manager</h2> <div class="col sidebar"> <ul class="nav_side"><li><a href="?page=blog">+ Add Post</a></li><?php$q = "SELECT * FROM blog ORDER BY date ASC";$r = mysqli_query($dbc, $q);if ($r) {while ($link = mysqli_fetch_assoc($r)) {echo '<li><a href="?page=blog&id='.$link['id'].'">'.$link['title'].'</a></li>';}}?></ul> < /div>< div class="col editor">< h1><?phpif (isset($_GET['id'])) {$q = "SELECT * FROM blog WHERE id = '$_GET[id]' LIMIT 1";$r = mysqli_query($dbc, $q);$opened = mysqli_fetch_assoc($r);echo 'Editing: '.$opened['title'];} else {echo 'Add a New Blog Post';}?>< /h1> <form action="?page=blog&id=<?php if (isset($_GET['id'])){echo $opened['id'];} ?>" method="post"><table class="gen_form"><tr><td class="gen_label"><label>Blog title: </label></td><td><input class="gen_input" type="text" size="30" name="title" value="<?php if (isset($_GET['id'])){echo $opened['title'];} ?>" /></td></tr><tr><td class="gen_label"><label>Blog date: </label></td><td><input class="gen_input" type="text" size="30" name="date" value="<?php if (isset($_GET['id'])){echo $opened['date'];} ?>"/></td></tr><tr><td class="gen_label"></td></tr><tr><td colspan="2" class="gen_label"><label>Blog body: </label></td></tr><tr><td colspan="2"><textarea id="page_body" name="body" cols="90" rows="24"><?php if (isset($_GET['id'])){echo $opened['body'];} ?></textarea></td></tr><tr><td colspan="2"><input class="gen_submit" type="submit" name="submit" value="Save Changes" /></td></tr><input type="hidden" name="submitted" value="1" /><input type="hidden" name="id" value="<?php if (isset($_GET['id'])){echo $opened['id'];} ?>" /></table></form><?php ?> </div> Two problems: 1. The timestamp being inserted into the database is 0000-00-00 00:00:00 2. The body content is being inserted into the database with paragraph tags around it (I am using Redactor WYSIWYG for the body field). What could be causing these two issues? Quote Link to comment https://forums.phpfreaks.com/topic/275574-timestamp-issue-and-wysiwyg-issue/ Share on other sites More sharing options...
teynon Posted March 13, 2013 Share Posted March 13, 2013 Wrap your code in the code block. -> Button that looks like <> <?php ## Blog Manager ?> <?php if (isset($_POST['submitted']) == 1) { if ($_GET['id'] == '') { if ($_POST['title'] == '' || $_POST['body'] == '') { header('Location: index.php?page=blog'); } else { $title = $_POST['title']; $date = $_POST['date']; $body = $_POST['body']; $q = "INSERT INTO blog (title, date, body) VALUES ('$title', '$date', '$body')"; } } else { $q = "UPDATE blog SET title = '$_POST[title]', date = '$_POST[date]', body = '$_POST[body]' WHERE id = '$_POST[id]'"; } $r = mysqli_query($dbc, $q); } ?> < h2>ATOM.CMS Blog Manager</h2> <div class="col sidebar"> <ul class="nav_side"> <li><a href="?page=blog">+ Add Post</a></li> <?php $q = "SELECT * FROM blog ORDER BY date ASC"; $r = mysqli_query($dbc, $q); if ($r) { while ($link = mysqli_fetch_assoc($r)) { echo '<li><a href="?page=blog&id=' . $link['id'] . '">' . $link['title'] . '</a></li>'; } } ?> </ul> < /div> < div class="col editor"> < h1> <?php if (isset($_GET['id'])) { $q = "SELECT * FROM blog WHERE id = '$_GET[id]' LIMIT 1"; $r = mysqli_query($dbc, $q); $opened = mysqli_fetch_assoc($r); echo 'Editing: ' . $opened['title']; } else { echo 'Add a New Blog Post'; } ?> < /h1> <form action="?page=blog&id=<?php if (isset($_GET['id'])) { echo $opened['id']; } ?>" method="post"> <table class="gen_form"> <tr> <td class="gen_label"><label>Blog title: </label></td> <td><input class="gen_input" type="text" size="30" name="title" value="<?php if (isset($_GET['id'])) { echo $opened['title']; } ?>" /></td> </tr> <tr> <td class="gen_label"><label>Blog date: </label></td> <td><input class="gen_input" type="text" size="30" name="date" value="<?php if (isset($_GET['id'])) { echo $opened['date']; } ?>"/></td> </tr> <tr> <td class="gen_label"></td> </tr> <tr> <td colspan="2" class="gen_label"><label>Blog body: </label></td> </tr> <tr> <td colspan="2"><textarea id="page_body" name="body" cols="90" rows="24"><?php if (isset($_GET['id'])) { echo $opened['body']; } ?></textarea></td> </tr> <tr> <td colspan="2"><input class="gen_submit" type="submit" name="submit" value="Save Changes" /></td> </tr> <input type="hidden" name="submitted" value="1" /> <input type="hidden" name="id" value="<?php if (isset($_GET['id'])) { echo $opened['id']; } ?>" /> </table> </form> <?php ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/275574-timestamp-issue-and-wysiwyg-issue/#findComment-1418290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.