You can use any existing user management, but you don't need any.
You should also tell the class if your user is authenticated or not. On this demo page I set the auth-value automatically to true and used your IP addresses as key to identify you.
Just include SBM script on every page where you like to offer bookmark function, initialize class and show form or bookmarks.
I suggest to upload needed files into an own directory, i.e. sbm
these are the files you'll need
sbm sbm.class.phpminimum with ajax support
sbm sbm.ajax.php sbm.class.php sbm.min.jswith ajax support, when jquery file is needed
sbm jquery.3.4.1.min.js sbm.ajax.php sbm.class.php sbm.min.js
usage of animate.min.css will be discussed at the end of the manual
you have to define at least the database connection settings
//DB Settings - only necessary if you're don't provide an existing DB-connectionThe setup routine will be called when accessing your website after you've included and initialized the class.
var $db_host = "localhost"; //change if needed!!
var $db_user = "hansGruber"; //change is needed!!
var $db_pass = "superSecret"; //change is needed!!
var $db_name = "nacatomi"; //change is needed!!
//Your bookmarks table
var $bm_table = "simpleBookmarks";
Include sbm.class.php and initialize Class on every page where you want to use the SBM functions
$sbm = new SimpleBM($uid,$auth,$db);
$sbm = new SimpleBM($uid,$auth);Filled in the values of $uid (15) and authenticated authentication status (1)
$sbm = new SimpleBM(15,1);Just the IP Address as key, there's no need to authenticatem so set it to 1
$sbm = new SimpleBM($_SERVER["REMOTE_ADDR"],1);Cookie based, if you use COOKIE in uppercase a cookie will be set (usefull on rotating IPs), there's no need to authenticatem so set it to 1
$sbm = new SimpleBM("COOKIE",1);
$sbm = new SimpleBM($email,$auth);
$sbm = new SimpleBM($user->email,$auth);
$sbm = new SimpleBM($user->id,$user->auth);
But it's essential to include the sbm.min.js after the jquery including and don't forget the id
PHPscriptUrl) and therefore the id
sbmjs has to be added to the script tag.
An uncompressed version is attached to the installation files too.
By clicking the link with the ID
bmf ... link can be generated automatically
... more info below
The value of the bookmarks will be increased by 1 after bookmarking, or reduced by 1 when unbookmarking. The number should be placed in an span with the classname
... more info below
Bookmarks can be removed by clicking the removing link in the bookmarks list (class
rmbm) and by clicking the link with the ID the link with the ID
... more info below
You can use the showLink() method anywhere on your pages to enable bookmarking/un-bookmarking
If page is bookmarked an "Un-Bookmark" link will be displayed, otherwise "Bookmark" link is shown.
<?php echo $sbm->showlink($title); ?>
echo $sbm->showlink("Title I like to get used for it");
<?php echo $sbm->showlink(); ?>into the header.php file, which is included on every page
To show your users their bookmarks and let them manage their you can call stored bookmarks
<?php echo $sbm->bookmarks($array); ?>
$arr = $sbm->bookmarks(true);
Display number of bookmarks of each page on the page itself
<?php echo $sbm->CountBM($url); ?>
echo $sbm->CountBM("http://yoursite.tld/yourpath/yourfile.php");to dynamically increase/decrease count use the
Bookmarked <span class="sbmcount"><?php echo $sbm->countBM(); ?></span> times
Bookmarked <span class="sbmcount"><?php echo $sbm->countBM(); ?></span> timesinto the header.php file, which is included on every page
To show your users their bookmarks in a dropdown and let them jump to the bookmarks you can use
<?php echo $sbm->bookmarksDropdown(); ?>
You can see this in the Bookmarks in this demo.
You could include this code anywhere on your page.
you can either use the
$layoutStyle-Array. For the array returns on bookmarks and bookmark stats you can build your own outputs. You could also modify the corresponding methods in the class to fit your needs.
var $layoutStyle = array(
//showed in showlink() method
"bookmarked_class" => "btn btn-outline-secondary",
"bookmarked_text" => "Bookmarked <i class='fas fa-bookmark'></i>",
"bookmark_class" => "btn btn-outline-primary",
"bookmark_text" => "Bookmark <i class='far fa-bookmark'></i>",
"show_bookmarks_link" => false,
"bookmarks_link_text" => "<small>[Your Bookmarks]</small>",
"bookmarked_success_text" => "This page has been bookmarked successfully.",
"removed_success_text" => "This page has been removed from your bookmarks successfully.",
"please_authenticate_to_view" => "Please authenticate to view your bookmarks",
"please_authenticate_to_bookmark" => "Please authenticate to bookmark",
//no bookmarks found on bookmark listing
"no_bookmarks_found" => "<strong>No bookmarks found</strong>",
//used on bookmarks list page
"remove_bookmark_text" => "<i class='fas fa-times'></i> remove bookmark",
"remove_bookmark_class" => "btn btn-outline-danger btn-sm",
"dateTimeFormat" => 'Y-m-d G:i', //more information on https://php.net/manual/en/function.date.php
//the select dropdown
"dropdown_select_class" => "form-control",
"dropdown_select_text" => "--Your Bookmarks--",
you get an overview of all stored bookmarks of all users with
echo <?php $sbm->BookmarkStats($array); ?>
$arr = $sbm->BookmarkStats(true);
if you like animated notifications when adding/removing bookmarks you can get those with animate.css
If your webproject already uses animate.css the notifications should be already animated, if notyou have to upload the animate.min.css into the bookmarks folder and add the param
data-option to the script tag