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_Add
<?
if(isset($_POST['snips_add_form'])) {
    if(!isset(
$_POST['cats'])) {
        echo 
"You should really have added a category before you try and add a snippet !!";
        die;
    }
    
$ob = new SNIPS;
    if(
$ob->snips_create($_POST['cats'], $_POST['title'], $_POST['syntax'], $_POST['description'])) {
        
        
$title $_POST['title'];
        
$reg = new regex;
        
$reg->set_string($title);
        
$new_title $reg->get_string();
        
        echo 
'</br><div align=center><b>Snippet Added !!</b></br>';
        echo 
'<a href=index.php?cat_select='.$_POST['cats'].'&show='.$new_title.'>click here to refresh and see changes.</a></br></div>';
        echo 
'<script language=javascript>
        alert("Snippet Added");
        document.location="index.php?cat_select='
.$_POST['cats'].'&show='.$new_title.'";
        </script>'
;
    } else {
        echo 
'some type of error happend, probably that a snippet with that name already exists</br>';
    }
}

echo 
'</br><form action='.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' method=post>';
echo 
'<table align=center class=table1 cellpadding=6><tr class=rowpic><td colspan=2>Add new snippet</td></tr><tr><td>';
echo 
'Select category: </td><td align=right><select name="cats">';
$all_cats cats_get();

foreach(
$all_cats as $cat) { 
    if(
strlen($cat) >1) {
        echo 
"<option value=$cat>$cat</option>\n";
    }
}
echo 
'</select></td></tr><tr><td>';
echo 
'Snippet title:</td><td align=right><input type=text maxlength=20 size=20 name=title></td></tr><tr><td colspan=2>';

echo 
'Enter Syntax below:</br><textarea name=syntax rows=10 cols=50></textarea></td></tr><tr><td colspan=2>';
echo 
'Enter Description below:</br><textarea name=description rows=6 cols=50></textarea></td></tr><tr align=center><td colspan=2>';
echo 
'<input type=button class=submit name=cancel OnClick="document.location=\'index.php\'" value=Cancel>&nbsp;&nbsp;';
echo 
'<input type=submit class=submit name=snips_add_form value=Add>';
echo 
'</td></tr></table></form>';
?>
 
Description for: PHP_CSL_6 . Snips_Add
Add a Snippet.