Fixing Timestamp Error


When I first added the timestamp¬†function to the code it seemed to work. While finishing the code and testing the site I saw that an error appeared and instead of it saying for example “10 mins ago” it said “-3457 seconds ago”. This meant that the filters for most recent were getting confused to I needed to fix the error.

Example of the error:

Screen Shot 2015-04-19 at 16.21.14

I spent a long time trying to fix the code and realised that it started from -3600 seconds which is an hour. I then realised that it could be because the clocks changed a few days after I finished this code. I then found an alternative to “UTC” as the default timezone on the code on the php site. I had tried other timezones such as EST and GMT just as a test but these apparently aren’t readable by the PHP. This seemed to work successfully and now I had an accurate timezone on my timestamp function.

Screen Shot 2015-04-19 at 16.18.09 Screen Shot 2015-04-19 at 16.17.57

Now the site looks this this:

Screen Shot 2015-04-19 at 16.25.30

Deleting a User’s Posts


As another extra feature of the site I wanted the user to be able to delete their post so they could either redo it or be able to update it. I had to add a new delete_post.php file and create an if statement so if the user was logged in then the delete button would appear and they were able to delete only their posts. I also created a message if they were not able to delete their post then it would appear with an error message.

Screen Shot 2015-04-19 at 16.49.17

I then needed to add the function to the box1.php as that is where I wanted the button to appear.

<!--?php if ($_SESSION["user_id"]==$row["user_id"]) {?--></pre>
<div id="delete_post" class="delete"><a id="" href="delete_post.php?id=<?php echo $row[">"><button class="btn btn-danger" type="button">Delete Post</button></a></div>
<pre><!--?php } ?-->
<!--?php } else { ?-->
    <!--?php } ?-->

I then wanted to style this button so the text would stand out in  the box and it actually looked like a delete button. I went onto Bootstrap and found the best delete button (the danger button) I could find and added it to the box1.php code.

Screen Shot 2015-04-19 at 16.53.58

This is what the final product looks like:

Screen Shot 2015-04-19 at 17.00.52