PHP Code Snippet Library
Available Snippets
+ Affichage

+ PHP_CSL_6

 + Snips_Add

 + Cats_Edit

 + Menu

 + Cats_Delete

 + Middle

 + Cats_Add

 + Snips_Delete

 + README

 + Index

 + Snips_Edit

 + Configuration

 + Classes

+ String_manipulation

+ Variables

Generic Options
+   Main page

+   Add new snippet

+   Add new category

+   Edit a category

+   Delete a category

Unique Options
+   Edit this snippet

+   Delete this snippet

+   Edit this category

+   Delete this category

Syntax for: PHP_CSL_6 . Snips_Delete
<?php
if(isset($_POST['snips_delete']) || isset($_GET['snips_delete'])) {
    if(!isset(
$_GET['snips_delete'])) {
        
$snips $_POST['snips'];
        
$cats $_POST['cats'];
    } else {
        
$snips $_GET['snips_delete'];
        
$cats $_GET['cats'];
    }
    
// double check that the user wishes to delete the selected snippet.
    
if(!isset($_POST['confirm'])) {
        echo 
'</br><form action='.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' method=post>';
        echo 
'<table align=center class=table1 cellpadding=6><tr class=rowpic><td>Delete a snippet</td></tr><tr align=center><td>';
        echo 
'<font color=red>Are you sure you want to delete \' '.$snips.' \' ?</font></td></tr><tr align=center><td>';
        echo 
'<input type=hidden name=confirm value=yes>';
        echo 
'<input type=hidden name=snips value='.$snips.'>';
        echo 
'<input type=hidden name=cats value='.$cats.'>';
        echo 
'<input type=button class=submit name=cancel OnClick="document.location=\''.$_SERVER['HTTP_REFERER'].'\'" value=No>&nbsp;&nbsp;';
        echo 
'<input type=submit class=submit name=snips_delete value=Yes>';
        echo 
'</td></tr></table></form>';
    } else {
        
// has the user has confirmed the deletion ??
        
if($_POST['confirm'] == "yes") {
            if(
file_delete($_POST['cats'],$_POST['snips'])) {
                echo 
'</br><div align=center><b>Snippet Deleted !!</b></br>';
                echo 
'<a href=index.php>click here to refresh and see changes.</a></br></div>';
                echo 
'<script language=javascript>
                alert("Snippet Deleted");
                document.location="index.php";
                </script>'
;
            } else {
                echo 
'some type of error happend.</br>';
            }
        }
    }
    
    
} else {
    echo 
"Oppps... you should not see this message, this page should not be accessed directly !";
}
?>
 
Description for: PHP_CSL_6 . Snips_Delete
Delete a Snippet.