Deleting a User’s Posts

Standard

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s