Ad block is installed and active. Please support us by disabling it.
HomeTuesday, February 20, 2018, 01:36:56
2

PHP/MySQL Bookmarklet - PHP Tutorial

Tuesday, February 10, 15, 14:50:49, 3 Yaers Ago Via wain, Hits: 4176
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 Write to File

PHP Write to File :: PHP Tutorial, requirement(s): PHP server

Upload File with PHP

Basic file uploading with PHP

PHP Form Basic

PHP Form - PHP form basic, Requirement(s): PHP Server

PHP Date Examples

Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given.

PHP getdate

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.

FeedBack Form with Captcha

It allows your visitors to send you an email directly from your website.

Link Base L.1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

PHP Trim

trim() Strip whitespace (or other characters) from the beginning and end of a string.

GuestBook PHP Script

Allow visitors to leave messages on your site. It features easy install, admin notification, and control panel to remove unwanted entries.

ShoutBox 1.1. PHP Script

ShoutBox allows your users to post short messages on your site. The script is lightweight and very easy to install and use.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Mon, Jan 29, 18
So far has created 115 entries.
wain
This author has not yet filled in any details.