Ad block is installed and active. Please support us by disabling it.
HomeSunday, August 20, 2017, 22:47:27
2

PHP/MySQL Bookmarklet - PHP Tutorial

Tuesday, February 10, 15, 14:50:49, 3 Yaers Ago Via wain, Hits: 3138
PHP/MySQL bookmarklet, bookmark current page, PHP/MySQL tutorial.
1. Import SQL file into your database.
import.sql
Code:
CREATE TABLE `weburl` (
`id` int(11) NOT NULL auto_increment,
`url` text collate utf8_unicode_ci,
`text` text collate utf8_unicode_ci,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


2. Create a Connection to a MySQL Database.
config.php
Code:
<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'mypassword';
$dbname = 'mydbname';
$conn=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conn) :
die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $conn);
if(!$db) :
die ('Cant connect to database : ' . mysql_error());
endif;
?>


Submit Form.
submit.php
Code:
<?php
include('config.php');
@$gettitle = $_GET['title'];
@$gettitle = addslashes ($gettitle);
@$geturl = $_GET['url'];
@$geturl = "http://" . $_GET['url'];
@$geturl = addslashes ($geturl);
if(isset($_POST['submit']))
{
$url = $_POST['url'];
$title = $_POST['title'];
$result = mysql_query("INSERT INTO weburl (url,text)
VALUES ('$url','$title')")
or die(mysql_error());
echo "Ok";
}else{
?>
<head>
</head>
<form action="submit.php" method="post">
<input type="hidden" name="url" value="<?php echo $geturl ?>">
<input type="text" name="title" value="<?php echo $gettitle ?>">
<input type="submit" value="Submit" name="submit">
</form>
<?php } ?>


4. Select From MySQL
mylinks.php
Code:
<?php
////make a MySQL connection
include('config.php');
//get url, text from the webpage table
//..or..*=select everything from the table weburl
$result = mysql_query("SELECT url, text FROM weburl
order by id desc")
or die(mysql_error());
while($myrow = mysql_fetch_assoc($result))
{
echo "<a href=\"$myrow[url]\">$myrow[text]</a><br />";
}
?>



Bookmarklet Link Code - Google Chrome Bookmarks Bar
Code:
Drag this link: <a href="javascript:(function(){f='http://www.example.com/submit.php?url='+location.href.replace(/http?:\/\//i, '')+'&title='+encodeURIComponent(document.title)+'ยต=451397693h74456&';a=function(){if(!window.open(f+'noui=1&jump=doclose','sharer321','location=no,links=no,scrollbars=no,toolbar=no,width=660,height=200'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()">Bookmark on Example.com</a> up to your Bookmarks Toolbar.






Sign In

Sponsor

Related

PHP Form Action Self Submit

PHP form action self submit tutorial, requirement(s): PHP server

Filter Words in PHP - PHP Tutorial

Filter bad words in PHP, requirement(s): PHP server

PHPBB3 Shoutbox

Vesion: 1.1. Released: 08/08/10, Licence GNU, Price: Free

RSS, MySQL & Smarty

Smarty > Publishing MySQL Data in RSS 2.0

Send This Link PHP Script

A popup form which allows your visitors to send a referral link from your site. It features admin notification and HTML output.

PHP filesize

The filesize function returns the size of the specified file.

Prevent the error loading XML โ€“ libxml_use_internal_errors

libxml_use_internal_errors() allows you to disable standard libxml errors and enable user error handling.

Upload Image With PHP

[Example3] Tutorial - How to upload image in php.

Addslashes - Stripslashes

addslashes โ€” quote string with slashes, stripslashes โ€” un-quotes a quoted string

Bookmark Script

Allow your users to easily bookmark your site, by clicking on a link on the page.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Thu, Jun 15, 17
So far has created 115 entries.
wain
This author has not yet filled in any details.