tag system revcms

Mexicano

El Patrón
Aug 14, 2013
363
175
Hey i added tags in my revcms theme and they add perfectly fine but when i click on the minus icon to delete it, it doesnt delete! It just stays there, any ideas why?

Code:
<div class="habblet-container">       
<div class="cbb clearfix green ">


<h2 class="title">Plugins</h2> </font><br>
<div class="box-tabs-container clearfix">
    <ul class="box-tabs">
        <li id="tab-1-5-2" class="selected"><a href="#">Tags</a><span class="tab-spacer"></span></li>
    </ul>
</div>


    <?php
    $my_id = $_SESSION['user']['id'];
    $fetch_tags = mysql_query("SELECT tag,id FROM user_tags WHERE user_id = '".$my_id."' LIMIT 20") or die(mysql_error());
    $tags_num = mysql_num_rows($fetch_tags);
    
    if (isset($_POST['remtag']))
    {
    $do = $_GET['do'];
    if($do != "") {
    mysql_query("DELETE FROM user_tags WHERE id = '".$do."'");
    Redirect("me");
    }
    }
    ?>
<div style="text-align: left;">
<?php
$my_id = $_SESSION['user']['id'];
$fetch_tags = mysql_query("SELECT tag,id FROM user_tags WHERE user_id = '".$my_id."' LIMIT 20") or die(mysql_error());




$do = $_GET['id']; 
if (isset($do))
{
    mysql_query("DELETE FROM user_tags WHERE id = '".$do."'");
    header("Location: me");
}
 
    if (isset($_POST['newtag']))
    {
    $user_id = $_SESSION['user']['id'];
    $tag = htmlspecialchars(addslashes($_POST[newtag]));
 
    if (strlen($user_id) < 1 || strlen($tag) < 1)
    {
    header("Location: me");
    }
    else
    {
        mysql_query("INSERT INTO user_tags (user_id,tag) VALUES ('" . $user_id    . "','" . $tag . "')");
    header("Location: me");
    }
    }
    ?>
    <div id="tab-3-2-content" >
    <div id="my-tag-info" class="habblet-content-info">
        <?php if($tags_num > 19){ echo "Sorry, but you have reached your tag limit"; }
        else
        if($tags_num == 0)
        { echo "You have no tags yet."; }
        ?>
    </div>
<div class="box-content">
    <div class="habblet" id="my-tags-list">
 
<?php if($tags_num > 0){
            echo "<ul class=\"tag-list make-clickable\"> ";
    while($row = mysql_fetch_assoc($fetch_tags)){
    echo ' <li>'.strtolower($row["tag"]).'</li>
                        <a href="{url}/index.php?url=me&id='.$row["id"].'"><input type="image" src="{url}/app/tpl/skins/{skin}/images/minus.png" href="{url}/index.php?url=me&id='.$row["id"].'"/></a>&nbsp;
           
    ';
    }
            echo "</ul>";
} ?>
 
<?php if($tags_num < 20){ ?>
    <form method="post">
    <div class="add-tag-form clearfix">
        <input type="submit" class="submit" name="newtag" value="Add it!" style="float: right">
        <input type="text" name="newtag" maxlength="20" style="float: right"/>
    </div>
    <div style="clear: both"></div>
    </form>
<?php } ?>
    </div>
</div>
</div>
                        <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
                    </div>
            </div>
            <script type="text/javascript">
                document.observe('dom:loaded', function() {
                    CurrentRoomEvents.init();
                });
            </script>
        </div>
 

JayC

Always Learning
Aug 8, 2013
5,504
1,401
This is why you shouldn't copy and paste code... Very Sloppy code actually.
href="{url}/index.php?url=me&id='.$row["id"].'"/> -> This calls to the DO

Try instead of this
PHP:
$do = $_GET['id'];
if (isset($do))
{
mysql_query("DELETE FROM user_tags WHERE id = '".$do."'");
header("Location: me");
}
Into This
PHP:
if(isset($_POST['id'])){
$tag = $_POST['id'];
mysql_query("DELETE FROM user_tags WHERE id='".$tag."'");
header("Location: me");
}
 

Mexicano

El Patrón
Aug 14, 2013
363
175
This is why you shouldn't copy and paste code... Very Sloppy code actually.
href="{url}/index.php?url=me&id='.$row["id"].'"/> -> This calls to the DO

Try instead of this
PHP:
$do = $_GET['id'];
if (isset($do))
{
mysql_query("DELETE FROM user_tags WHERE id = '".$do."'");
header("Location: me");
}
Into This
PHP:
if(isset($_POST['id'])){
$tag = $_POST['id'];
mysql_query("DELETE FROM user_tags WHERE id='".$tag."'");
header("Location: me");
}
Didnt work :L
 

Users who are viewing this thread

Top